Why doesn’t Postman get a “No 'Access-ControlAllow-Origin' header is present on the requested resource” error in JavaScript


Problem:

When we try to make network request to a remote server whose origin is different to our current url (from which we are making the request), we most likely get a CORS error due to different origin problem in the web, whereas while using a tool like Postman, we can successfully avoid this CORS error.

We are required to explain the difference in behaviour of response when requested through web and when requested through an extension like postman.

Explanation:

When we make a network request to a different domain than our page is on using a web browser, it blocks that request and without even notifying or reaching out to the server and usually allows a request in the same origin for security reasons.

But when we are using Postman or any such tool, they are not restricted by this policy. Web pages can use the XMLHttpRequest object to send and receive data from remote servers, but they're limited by the same origin policy but the extensions like Postman are not so limited. An extension can talk to remote servers outside of its origin and this is the reason why Postman successfully makes requests while the webpages fails due to CORS error.

Updated on: 22-Feb-2021

655 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements