CORS请求无效 - 缺少标头?

时间:2014-09-03 05:00:51

标签: http-headers cors

我正在尝试将图像上传到finagle(netty)服务器。对于OPTIONS请求,我返回以下内容:

curl -X OPTIONS http://localhost:8686/images -i                                                         
  HTTP/1.1 200 OK
  Access-Control-Allow-Origin: *
  Access-Control-Allow-Methods: POST

浏览器(FireBug):http://s15.postimg.org/vtdzyfshn/Screen_Shot_2014_09_02_at_9_49_05_PM.png

以下POST请求失败并带有

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote 
resource at http://localhost:8686/images. This can be fixed by moving the resource 
to the same domain or enabling CORS.

FireBug 1(控制台):http://s30.postimg.org/9utq4ridt/Screen_Shot_2014_09_02_at_9_53_41_PM.png FireBug 2(网络标签):http://s16.postimg.org/jyblxfcv9/Screen_Shot_2014_09_02_at_9_54_37_PM.png FireBug 3(网络标签 - POST):http://s14.postimg.org/e8czua2wh/Screen_Shot_2014_09_02_at_9_54_47_PM.png

知道我错过了什么吗?

(我正在使用此上传脚本:http://www.extremecss.com/creating-asynchronous-file-upload-system-using-html5-file-api/

1 个答案:

答案 0 :(得分:0)

您必须将响应标头内的CORS标头(Access-Control-Allow-Origin:*)返回到POST,而不是在OPTIONS响应中。