I have a strange issue after migrating from Heroku to another PAAS(Aptible).
When I make jsonp requests on the android device, they fail with status code 0(from what I understand - all error codes get eaten by javascript due to the nature of jsonp) and an undefined data object. The same requests to the exact same Api on my staging server(which is on heroku) work perfectly fine, with status code 200. In the browser, the requests both work fine and return a 200 from both servers. Only on the actual android device do I get this problem. This problem occurs on all android devices(I’ve tested about 6 different devices now). The request and response headers are the same for both servers. The new web server, where the problem occurs, does not even see the request in its Rails logs(although it is possible that the request gets to the server, and something is happening on the nginx server which stops the request).
Example:
$http.jsonp(
'https://[myserver]/api/auth?callback=JSON_CALLBACK&email=[redacted]&password=[redacted]'
).
success(function(data, status, headers, config) {
console.log("success");
console.log("data", data);
console.log("status", status);
console.log("headers", headers);
console.log("config", config);
}).
error(function(data, status, headers, config) {
console.log("fail.");
console.log("data", data);
console.log("status", status);
console.log("headers", headers);
console.log("config", config);
});
This results in the following response on device(from Weinre):
As I said, the request and response headers are almost identical, the only differences is in two headers:
response header X-xss-protection
problem server(Aptible): X-XSS-Protection:1; mode=block
working server(Heroku): X-Xss-Protection:1; mode=block
But this shouldn’t matter, as the HTTP spec says header capitalization shouldn’t matter, so unless the device cares about this, it should be irrelevant.
Other response header differences:
problem server(Aptible): Server:Cowboy
good server(Heroku): Server:nginx/1.6.0
problem server(Aptible): Via:1.1 vegur
good server(Heroku): this header is not returned at all
Shout out to @tyvdh who has also been trying to help me debug this issue.