Home  >  Article  >  Web Front-end  >  Why don't Postman get the "'Access-ControlAllow-Origin' header does not exist on the requested resource" error in JavaScript

Why don't Postman get the "'Access-ControlAllow-Origin' header does not exist on the requested resource" error in JavaScript

WBOY
WBOYforward
2023-08-24 17:45:06546browse

为什么 Postman 在 JavaScript 中没有收到“请求的资源上不存在‘Access-ControlAllow-Origin’标头”错误

Problem:

When we try to make a network request to a remote server whose origin is different from the current url (from which we are making the request), we are likely CORS errors are received due to different origin issues in the network, and while using a tool like Postman, we can successfully avoid this CORS error.

We need to explain the difference in response behavior when requesting over the network When requested via an extension like Postman.

Description:

When we use the network to make a network request to a domain that is different from the domain where our page is located the browser, which blocks the request without even notifying or contacting the server, For security reasons, same-origin requests are usually allowed.

But when we use Postman or any such tool, they are not restricted by this policy. network Pages can use XMLHttpRequest objects to send and receive data from remote servers, but They are subject to the same-origin policy, but extensions like Postman are not. one Extensions can communicate with remote servers outside of their origin, that's why Postman The request was made successfully, but the page failed with a CORS error.

The above is the detailed content of Why don't Postman get the "'Access-ControlAllow-Origin' header does not exist on the requested resource" error in JavaScript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete