blocked by CORs pollcy: Response to preflinht reguest doesn't pass access control check: It does not have HTTp ok status
时间: 2023-10-16 11:03:08 浏览: 90
corsyusha:简单快速的代理,可在针对现有API进行原型设计时绕过CORS问题,而不必担心CORS
引用和中提到的错误是关于CORS (跨域资源共享)策略的问题。CORS是一种安全机制,用于限制从一个域名下的网页去请求另一个域名下的资源的方式。当浏览器发起跨域请求时,服务器需要在响应中添加特定的头部字段来允许请求的源进行访问。如果服务器没有正确配置这些头部字段,浏览器就会阻止访问,并报错"blocked by CORS policy"。
在你提供的引文中,报错信息中提到的问题是"Response to preflight request doesn't pass access control check: It does not have HTTP ok status"。这意味着在进行跨域请求时,预检请求的响应状态码不是HTTP 200 OK,而是其他的状态码。
要解决这个问题,可以参考以下步骤:
1. 检查预检请求的响应是否返回了HTTP 200 OK状态码。如果没有,请确保服务器正确处理预检请求,并返回正确的状态码。
2. 检查服务器是否正确配置了"Access-Control-Allow-Origin"头部字段。这个字段的值应该设置为允许访问的源,可以是具体的域名或通配符"*",表示允许任何源进行访问。
3. 检查服务器是否正确处理OPTIONS请求。在进行跨域请求时,浏览器会首先发送一个OPTIONS请求进行预检,服务器需要正确处理这个请求,并返回合适的响应。
通过正确配置服务器的CORS策略,你应该能够解决"blocked by CORS policy"的问题,并使跨域请求能够成功进行。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [has been blocked by CORS policy: Response to preflight request doesn‘t pass access control chec](https://blog.csdn.net/qq_39408664/article/details/130195520)[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^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [has been blocked by CORS policy: Response to preflight request doesn‘t pass access control check: ...](https://blog.csdn.net/m0_46833693/article/details/124016734)[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^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [has been blocked by CORS policy: Response to preflight request doesn‘t pass access control check](https://blog.csdn.net/csdn_avatar_2019/article/details/126538547)[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^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文