我想在交叉域中使用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}]
我没有进一步的想法让它发挥作用。
答案 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标头。