I've added the CORS headers to my response object on the server and all desktop browsers allow ajax calls to return perfectly. However , i don't see the data coming in on any mobile browser and it turns out its a CORS error
Any ideas why this might happen?
CLIENT CODE:
getCharacter(completionFunc){
$.ajax("http://somewhere.com/api/character/0", {
//dataType: 'jsonp',
success: function(data) {
completionFunc(data);
}
});
}
SERVER HEADERS CODE (laravel):
public function handle($request, Closure $next)
{
return $next($request)
->header("Access-Control-Allow-Origin","*")
->header("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS");
}
Before adding the headers to the server i was getting a cors error on desktop browsers (as expected). Adding them fixed it, but not on mobile. Is there any significant difference between chrome mobile/desktop when it comes to handling CORS? ( i also tried the jsonp dataType on the ajax call but that didnt work)