Questions tagged «django-cors-headers»

7
CORS:当凭据标志为true时,不能在Access-Control-Allow-Origin中使用通配符
我有一个涉及的设置 前端服务器(Node.js,域:localhost:3000)<--->后端(Django,Ajax,域:localhost:8000) 浏览器<-webapp <-Node.js(为应用提供服务) 浏览器(webapp)-> Ajax-> Django(服务ajax POST请求) 现在,我的问题是CORS设置,Web应用程序使用它来对后端服务器进行Ajax调用。在Chrome中,我不断 当凭据标志为true时,不能在Access-Control-Allow-Origin中使用通配符。 在Firefox上也不起作用。 我的Node.js设置是: var allowCrossDomain = function(req, res, next) { res.header('Access-Control-Allow-Origin', 'http://localhost:8000/'); res.header('Access-Control-Allow-Credentials', true); res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE'); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); next(); }; 而在Django我使用这个中间件 与此相伴 Webapp发出这样的请求: $.ajax({ type: "POST", url: 'http://localhost:8000/blah', data: {}, xhrFields: { withCredentials: true }, crossDomain: true, dataType: …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.