【问题标题】:CORS request not valid - missing headers?CORS 请求无效 - 缺少标头?
【发布时间】:2021-04-21 00:16:05
【问题描述】:

我正在尝试将图像上传到 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/

【问题讨论】:

  • 您是否在 POST 响应的标头中返回 CORS 标头?
  • 天哪,我试过了,忘记重启服务器了。我改变了它并且它有效。 duh 如果您将此添加为答案,我会接受!
  • 偶尔发生在我们所有人身上:)

标签: http-headers cors


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2021-12-19
    • 2015-11-28
    • 1970-01-01
    • 1970-01-01
    • 2018-10-31
    • 2018-04-15
    • 1970-01-01
    • 2018-03-20
    • 1970-01-01
    相关资源
    最近更新 更多