saipavan
saipavan

Reputation: 81

Response for preflight has invalid HTTP status code 500 in angular 4

I am trying to consume services written in c# from my Angular 4 web application. when i make a POST request to the service, i am getting "Response for preflight has invalid HTTP status code 500" in chrome and in the server the POST request body values are null. But when i make the same request through POSTMAN, I am getting the proper response.

Thanks !!

Upvotes: 0

Views: 334

Answers (1)

oreofeolurin
oreofeolurin

Reputation: 636

It mostly has to do with CORS policy. The server blocked the request during the preflight OPTIONS request. So enable CORS on your server.

Here is why POSTMAN works:

Regular web pages can use the XMLHttpRequest object to send and receive data from remote servers, but they're limited by the same origin policy. Extensions aren't so limited. An extension can talk to remote servers outside of its origin, as long as it first requests cross-origin permissions.

So basically POSTMAN is an extension and doesn't care about CORS

Upvotes: 1

Related Questions