Skip to content Skip to sidebar Skip to footer

404 Error On Mobile Device But Works On Pc Browser

This might be a dumb question...but I am trying to make my first app using phonegap and dojo. I am able to use ajax and read some data from the server. This works fine on the and

Solution 1:

wild guesses 1) your server may be expecting proper headers

Accept: application/json

web browsers uses wildcards by default (Accept: /)

2) your server maybe filtering out using ua-agent headers and rejects non-web browsers

Solution 2:

I had very similar symptoms in my current PhoneGap project. When I was trying to reach my nginx/PHP backend with a jQuery call:

var jqxhr = $.post(SERVER_URL, {'some': 'parameters', 'another': 'parameter'}, null, "jsonp")
    .done(function (data) {
            // Success, do something...
    })
    .fail(function (data) {
            // Failed, do something...
    });

...the connection failed with 404 when using SSL. If the SERVER_URL pointed to a http URL the call worked all right. There were no redirections whatsoever on the server. According to the server logs the backend was executed and it returned the correct JSON-formatted output.

The code failed only with Android 6.x (did not test earlier) but worked all right with iOS 10.x (did not test earlier) as well as Firefox and Chromium.

The reason was that my nginx configuration had following options:

add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;

It appears that the other platforms did not respect these headers as the Android did.

Solution 3:

recently I faced similar problem, happens when you try to connect to http://localhost from Android emulator. see this thread which contains nice solution -> Accessing webserver running within Eclipse from outside the workstation

simple solution: when you want to access localhost from Android emulator, you should use 10.0.2.2

Solution 4:

Thanks everyone for the help. It ended up being casued by nginx rerouting the mobile requests to a server where the app was not hosted. Hence the 404 errors.

Post a Comment for "404 Error On Mobile Device But Works On Pc Browser"