javascript - jQuery 'Request header field token is not allowed by Access-Control-Allow-Headers'

标签 javascript cors

我正在通过 AJAX 上传文件。但是,我收到此错误:

Request header field token is not allowed by Access-Control-Allow-Headers

这是我上传到的网站的响应 header ,响应 header 看起来都很好:

HTTP/1.1 200 OK
Access-Control-Allow-Headers: X-Requested-With, X-Prototype-Version, Content-Disposition, Cache-Control, Content-Type
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Origin: http://admin.lvho.st:9292
Access-Control-Max-Age: 1728000
Cache-Control: no-cache
Content-Encoding: gzip
Content-Type: text/plain; charset=utf-8
Date: Wed, 22 Jan 2014 03:01:25 UTC
Server: cloudinary
Status: 200 OK
X-Request-Id: 3a74ab61f56ae7620c8ffbb5440b75b6
X-UA-Compatible: IE=Edge,chrome=1
transfer-encoding: chunked
Connection: keep-alive

这是请求 header :

OPTIONS /v1_1/*****/image/upload HTTP/1.1
Host: api.cloudinary.com
Connection: keep-alive
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Request-Method: POST
Origin: http://admin.lvho.st:9292
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36
Access-Control-Request-Headers: accept, token, content-type
Accept: */*
Referer: http://admin.lvho.st:9292/venue/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8

响应 header 中是否有遗漏/错误的内容?

谢谢

最佳答案

预检 (OPTIONS) 响应中的 Access-Control-Allow-Headers header 缺少对“ token ” header 的引用。您将需要更新您的服务器响应以说明此 header 。

关于javascript - jQuery 'Request header field token is not allowed by Access-Control-Allow-Headers',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21273499/

相关文章:

javascript - AngularJS:请求的资源上不存在 "Access-Control-Allow-Origin" header

javascript - CORS:预检响应中的 Access-Control-Allow-Headers 不允许 Content-Type

php - 在单个警报中显示多个文件输入的所有文件名

javascript - 如何在 native JavaScript 中使用边距、填充、边框获取元素宽度/高度(无 jQuery)

javascript - D3 过渡。在折线图上使用多条线,并希望在按下按钮时在线之间平滑过渡

javascript - 如何避免在 Node 中插入重复记录,sqlite [knex,objectionJS]

javascript - 当你不控制服务器时跨源资源共享?

nginx - Cors 在 Nginx 上阻止状态为 403 的请求

javascript - 使用 npm angular2 导入库

node.js - NodeJS/Express PUT 请求失败并显示 : No 'Access-Control-Allow-Origin' header is present on the requested resource