Request header field retoken is not allowed by Access-Control-Allow-Headers in preflight response.
时间: 2024-04-24 12:24:02 浏览: 106
这个错误是由于CORS策略引起的。CORS(跨域资源共享)是一种浏览器安全机制,用于限制跨域请求。当浏览器发起跨域请求时,会先发送一个预检请求(preflight request)来检查服务器是否允许该请求。预检请求中会包含一些自定义的请求头,如token、AC-User-Agent等。服务器需要在响应的请求头中设置Access-Control-Allow-Headers来允许这些自定义请求头。
根据引用\[1\]和引用\[2\]的错误信息,可以看出服务器没有正确设置Access-Control-Allow-Headers来允许token和AC-User-Agent这两个自定义请求头。根据引用\[3\]的经验,可以尝试在服务端过滤器的Response响应的请求头中设置Access-Control-Allow-Headers为'token,content-type'来允许这两个请求头。这样就可以解决"Request header field retoken is not allowed by Access-Control-Allow-Headers in preflight response"的问题了。
#### 引用[.reference_title]
- *1* *3* [Request header field token is not allowed by Access-Control-Allow-Headers in preflight response](https://blog.csdn.net/fuzhongbin/article/details/106239664)[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^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [解决Request header field XXX is not allowed by access-control-allow-headers in preflight response](https://blog.csdn.net/HO1_K/article/details/126501541)[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^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文