使用fineuploader的CORS

时间:2017-08-17 09:42:50

标签: .htaccess cors fine-uploader

我想在交叉域中使用fineuploader。 我收到Request header field Cache-Control is not allowed by Access-Control-Allow-Headers in preflight response.错误。

我的fineuploader配置是:

        request: {
            endpoint: "http://api.polskieszlaki.local/4adm/zdjecia/fileupload",
        },
        cors: {
            expected: true,
        },

.htaccess我的apache服务器上

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE"
Header set Access-Control-Allow-Headers "Content-Type, Authorization"

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

我没有进一步的想法让它发挥作用。

1 个答案:

答案 0 :(得分:1)

问题中引用的消息表明您必须将.htaccess更改为Cache-Control响应标头的值集Access-Control-Allow-Headers,并且因为the Fine Uploader docs表示发送X-Requested-With标题,然后您需要:

Header set Access-Control-Allow-Headers "Cache-Control, Content-Type, Authorization, X-Requested-With"

MDN docs for the Access-Control-Allow-Headers response header解释:

  

Access-Control-Allow-Headers标头用于响应预检请求,以指示在发出实际请求时可以使用哪些HTTP标头。