Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CORS with POSTMAN

Tags:

http

cors

postman

This subject has been asked a couple of time, but I still don't understand something:

When I read answers about

No 'Access-Control-Allow-Origin' header

issue, it says a setting should be set on the requested server in order to allow cross domain: add_header 'Access-Control-Allow-Origin' '*';.

But, please tell me why when asking from postman (which is a client), It's working like a charm and I have a response from the requested server?

Thank you

like image 699
IsraGab Avatar asked Mar 27 '16 17:03

IsraGab


People also ask

Does CORS work with Postman?

Postman does not implement the CORS restrictions, which is why you don't see the same error when making the same call from Postman.

How do you allow CORS for Postman?

Where it checks for Access-Control-Allow-Origin . Taking this into account Access-Control-Allow-Origin header just specifies which all CROSS ORIGINS are allowed, although by default browser will only allow the same origin. Postman: Sends direct GET , POST , PUT , DELETE etc.

What is Origin header in Postman?

You can use Postman to make an HTTP request with an Origin header. Your server can then send back an appropriate Access-Control-Allow-Origin header. However, Postman won't do anything with it except display it in the list of response headers.


2 Answers

CORS (Cross-Origin Resource Sharing) and SOP (Same-Origin Policy) are server-side configurations that clients decide to enforce or not.

Related to clients

  • Most Browsers do enforce it to prevent issues related to CSRF attack.
  • Most Development tools don't care about it.
like image 156
Felipe Roos Avatar answered Oct 11 '22 13:10

Felipe Roos


As @Musa comments it, it seems that the reason is that:

Postman doesn't care about SOP, it's a dev tool not a browser

By the way here's a chrome extension in order to make it work on your browser (this one is for chrome, but you can find either for FF or Safari).

Check here if you want to learn more about Cross-Origin and why it's working for extensions.

like image 73
IsraGab Avatar answered Oct 11 '22 12:10

IsraGab