我正试图从一个假装是远程web服务器的静态页面发布到我的Flask应用程序中,因为Flask-uWSGI-WebSocket而运行在uwsgi之后。
每次我投递到服务器时,帖子都会因为CORS:XMLHttpRequest cannot load http://127.0.0.1:5000/tnw/post. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.而被阻塞。
我已经安装了flask-cors,源代码设置为*,但我仍然无法让它通过。我还错过了什么?
我的帖子:$("#ajaxbutton").click(function() { var json = JSON.stringify(generate_json()); $.post('http://127.0.0.1:5000/tnw/post', json); });
发布于 2014-03-13 21:04:23
我认为这是两个问题之一:
file://协议而不是http://请求CORS的页面。这导致您拥有一个origin of 'null'。尝试使用通过http://访问它(例如,python -m SimpleHTTPServer)。{xhrFields: withCredentials: true}添加到ajax请求(文档)中。https://stackoverflow.com/questions/22385264
复制相似问题