Access-Control-Allow-Headers不允许使用“请求标头字段标记”

时间:2014-01-22 03:17:12

标签: javascript cors

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

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

以下是我上传到的网站的响应标题,响应标题似乎都很好:

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

这是请求标题:

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

响应标题中是否存在缺失/错误的内容?

由于

1 个答案:

答案 0 :(得分:4)

对预检(OPTIONS)的响应中的Access-Control-Allow-Headers标头缺少对“token”标头的引用。您需要将服务器响应更新为此标头的帐户。