has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
时间: 2023-10-23 15:48:15 浏览: 39
This error occurs when a web page's JavaScript code tries to access data from a different domain or origin than the one the page is hosted on, and the server hosting that data does not allow cross-origin requests.
In simple terms, the server that hosts the data needs to explicitly allow requests from the domain or origin of the webpage making the request. This is done by adding the appropriate "Access-Control-Allow-Origin" header to the server's response to the request.
To fix this error, you can try the following solutions:
1. Configure the server hosting the data to include the "Access-Control-Allow-Origin" header in its response to allow cross-origin requests from the domain or origin of the webpage making the request.
2. Use a proxy server to make the request on behalf of the web page, since the proxy server's origin will be the same as the web page's origin.
3. Use JSONP (JSON with Padding) to retrieve the data, which bypasses the same-origin policy by using a callback function to pass the data back to the web page.