CORS:Firefox在成功的OPTIONS请求...后不会发送POST请求...适用于Chrome [英] CORS: Firefox does not send POST Request after successful OPTIONS request … works in Chrome

查看:4299
本文介绍了CORS:Firefox在成功的OPTIONS请求...后不会发送POST请求...适用于Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到类似的问题,因为这篇文章,但最好的答案没有帮助我。如果任何人有任何其他想法,我会非常感谢。以下是请求:

I'm running into a similar issue as this post but the best answer did not help me out. If anybody has any other ideas, I would greatly appreciate it. Here are the requests:

请求标题

选项

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.实际请求包含content-length,content-type,x-annotator-auth-token和x-csrftoken,但没有获取状态代码,就好像它从未触发过。再次任何帮助将不胜感激!感谢

It returns with a status code of 200. The actual request contains content-length, content-type, x-annotator-auth-token, and x-csrftoken but gets no status code as if it never fired. Again any help would be appreciated! Thanks

推荐答案

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


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

response.addHeader("Access-Control-Allow-Origin", "*"); or
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);

//将其添加到您的响应标头,它将工作

and
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

这篇关于CORS:Firefox在成功的OPTIONS请求...后不会发送POST请求...适用于Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆