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
javascript angularjs firefox google-chrome cors


source to share


No one has answered this question yet

See similar questions:

99
Firefox 'Cross-Origin Request Blocked' Despite Headers
12
Deployd - data fetched via AngularJS CORS

or similar:

7649
How does JavaScript blocking work?
4523
Thinking in AngularJS if I have a jQuery background?
3178
AngularJS: Service vs provider vs factory
2268
Why does my JavaScript code get the error "No Access-Control-Allow-Origin header" on the requested resource ", but Postman doesn't?
1690
How does data binding work in AngularJS?
1403
Disable Same Origin Policy in Chrome
892
How to manually trigger HTTP POST requests using Firefox or Chrome?
317
Preflight request response fails access control check
299
jQuery $ .ajax (), $ .post sends "OPTIONS" as REQUEST_METHOD in Firefox
252
AngularJS makes HTTP OPTIONS request for cross origin resource



All Articles
Loading...
X
Show
Funny
Dev
Pics