【问题标题】:CORS: Firefox does not send POST Request after successful OPTIONS request … works in ChromeCORS:成功 OPTIONS 请求后,Firefox 不发送 POST 请求……在 Chrome 中有效
【发布时间】:2014-09-07 11:47:09
【问题描述】:

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

请求标头

选项

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

响应标头

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,但没有获得状态码,就好像它从未触发过一样。再次感谢任何帮助!谢谢

【问题讨论】:

  • 是否有可能链接到显示问题的测试用例?这将使这很容易确定....

标签: google-chrome firefox cross-domain cors


【解决方案1】:
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

【讨论】:

  • 这里必须明确设置原点。
猜你喜欢
  • 2014-01-18
  • 2015-09-01
  • 2023-03-14
  • 2016-12-26
  • 2014-04-16
  • 2017-03-13
  • 2012-12-31
  • 2014-09-03
  • 2019-08-29
相关资源
最近更新 更多