gpt4 book ai didi

google-chrome - CORS:Firefox 在成功的 OPTIONS 请求后不发送 POST 请求……在 Chrome 中有效

转载 作者:行者123 更新时间:2023-12-01 23:54:35 31 4
gpt4 key购买 nike

我遇到了与 this post 类似的问题但最好的答案并没有帮助我。如果有人有任何其他想法,我将不胜感激。以下是要求:

请求 header

选项

Access-Control-Request-Method:  POST
Access-Control-Request-Headers: content-type,x-annotator-auth-token,x-csrftoken

响应 header

Access-Control-Max-Age: 3600
Access-Control-Allow-Origin: http://localhost:8000
Access-Control-Allow-Methods: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS
Access-Control-Allow-Headers: content-length, content-type, x-annotator-auth-token, x-requested-with, x-csrftoken
Access-Control-Allow-Credentials: true

它返回状态代码 200。实际请求包含内容长度、内容类型、x-annotator-auth-token 和 x-csrftoken,但没有获得任何状态代码,就好像它从未触发过一样。再次感谢任何帮助!谢谢

最佳答案

response.addHeader("Access-Control-Allow-Origin", "*"); 

response.addHeader("Access-Control-Allow-Credentials","true");  

response.addHeader("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE, OPTIONS");  
response.addHeader("Access-Control-Allow-Headers", "Content-Type, X-Experience-API-Version,Authorization");
//add this into your response header and it will work

关于google-chrome - CORS:Firefox 在成功的 OPTIONS 请求后不发送 POST 请求……在 Chrome 中有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24789416/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com