Access-Control-Allow-Origin' header is present on the requested resource
时间: 2023-10-15 07:30:10 浏览: 106
引用中提到了一个错误信息,即"No 'Access-Control-Allow-Origin' header is present on the requested resource."。这个错误是由于被请求的资源没有设置"Access-Control-Allow-Origin"头部字段,导致来自"http://localhost:8080"的请求被拒绝访问。
要解决这个问题,可以使用引用中的配置来设置相应的头部字段,即添加以下配置:
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET,POST';
这样可以使配置生效,并解决这个问题。
另外,引用中提到,如果响应头中没有"Access-Control-Allow-Origin"参数,就会出现这个问题。因此,要解决这个问题,可以检查响应头是否包含该参数,并根据需要进行相应的设置。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [No 'Access-Control-Allow-Origin' header is present on the requested resource', 跨域访问的解决方法](https://blog.csdn.net/xujinggen/article/details/83999391)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [Nginx跨域设置Access-Control-Allow-Origin无效的解决办法](https://download.csdn.net/download/weixin_38702726/14091234)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [No 'Access-Control-Allow-Origin' header is present on the requested resource. 跨域问题!](https://blog.csdn.net/shasiqq/article/details/86614830)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文