'Access-Control-Allow-Origin' header is present on the requested resource.
时间: 2023-08-27 09:22:49 浏览: 116
This error typically occurs when making a cross-origin request from a web browser. The 'Access-Control-Allow-Origin' header is a security measure used by servers to control which domains can access their resources.
To resolve this issue, the server needs to include the 'Access-Control-Allow-Origin' header in its response. The value of this header should be the origin of the requesting domain, or "*" to allow any domain to access the resource.
For example, if you're using JavaScript to make a request from "example.com" to "api.example.com", the server at "api.example.com" should include the following header in its response:
```
Access-Control-Allow-Origin: https://example.com
```
This allows the browser to access the resource from the specified domain. If you want to allow requests from any domain, you can use "*" as the value:
```
Access-Control-Allow-Origin: *
```
Keep in mind that allowing requests from any domain may pose security risks, so it's generally recommended to specify the exact domain(s) that should be allowed.
阅读全文