Mitesh
Mitesh

Reputation: 108

Angular 2 - Chrome and IE(11) CORS issue

I am running angular 2 app(using angular-cli) and making a server API call(where CORS access for all(*) is implemented within the API code).

Now, when i am trying to make an API call from the angular 2 app,sometime i am getting the response from the server with no CORS issues at all and sometime i am getting below issue:

For Chrome browser:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

XMLHttpRequest cannot load https://server.com/api/currency.
No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 500.

For IE(11) browser

SEC7120: Origin http://localhost:4200 not found in Access-Control-Allow-Origin header.
File: localhost:4200
SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.
File: localhost:4200

For both the above browser the the response header returns

Response : HTTP/1.1 500 Interenal Server Error
Content-Length : 0

I also tried clearing the browser cache,but it's not working as expected and am getting above issue again.

Any help with above would be really appreciated.

Thanks!!

Upvotes: 1

Views: 1332

Answers (1)

Mateusz Woźniak
Mateusz Woźniak

Reputation: 1499

There is a problem with your backend. You are receiving a message that the server responded with a status of 500 (Internal Server Error), it means that some exception has occured there and that's why no proper headers were set to the response.

Check apache logs to find out what's happening there.

Upvotes: 2

Related Questions