1

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!!

Mitesh
  • 108
  • 1
  • 11
  • It seems to me that the [topic](http://stackoverflow.com/questions/36002493/no-access-control-allow-origin-header-in-angular-2-app) was many times. – Jaroslaw K. Jan 16 '17 at 22:00
  • I am facing the same problem. I'm using OSX El Capitan 10.11.6, Chrome 58.0.3029.96. The problem doesn't happen on Safari. – Juangui Jordán May 12 '17 at 17:24

1 Answers1

2

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.

Mateusz Woźniak
  • 1,479
  • 1
  • 9
  • 10