CORS works in chrome but not firefox, angularjs

I am trying to use angularJS with Jetty backend.

Preflight CORS requests work fine in chrome, but in firefox I get this CORS error: Cross-origin request blocked: Same origin policy disallows reading remote resource at http: //remote.machine: 8080 / api / v1 / provisioning / users / current -user . This can be fixed by moving the resource to the same domain or by enabling CORS.

The headers for requesting parameters are as follows:

HTTP/1.1 200 OK
Date: Wed, 24 Sep 2014 16:06:12 GMT
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
X-Frame-Options: DENY
Access-Control-Allow-Methods: GET, PUT, POST, OPTIONS, DELETE
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: Access-Control-Allow-Headers: Origin, Authorization, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Credentials: true
Set-Cookie: JSESSIONID=eyv8cpnnfphy1b0121uzt293y;Path=/
Content-Length: 0
Server: Jetty(9.2.2.v20140723)

      

The angular request is configured like this:

$http.get(AS_API_URL + '/provisioning/users/current-user', {
            headers: {
                'Authorization': 'Basic ' + base64EncodedAuth               
            }
        });

      

For some reason, these headers work fine in Chrome, but not Firefox, does anyone know why? Do I need to provide additional information?

EDIT:

Musa was correct that the Access-Control-Allow headers were wrong. I edited Jetty Server so the header now reads:

Access-Control-Allow-Headers: Origin, Authorization, X-Requested-With, Content-Type, Accept

      

I thank you Musa, you just saved my day :)

+3


source to share





All Articles