我正在通过 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/