我在httpd.conf中写了关于Apache的这些行:
<IfModule mod_headers.c>
Header always set Access-Control-Allow-Origin: *
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding"
</IfModule>
在浏览器的控制台中我有这个错误:
XMLHttpRequest cannot load '...'. The request was redirected to '...', which is disallowed for cross-origin requests that require preflight.
我在网络中看到了请求,响应标头是正确的。
我错了什么?
答案 0 :(得分:0)
根据this answer Apache正在做正确的事情。其他答案也可能有所帮助。
您可以为预先发出的请求返回200;在带有必要标题的重定向之前,为OPTIONS请求返回200.