我正在运行我的apache
http://localhost:8083
我正在调用本地box上托管的API。
http://localhost:8082
我想要地图
http://localhost:8083/test-call/abc/authorize
呼叫实际服务呼叫,即。
http://localhost:8082/TestCall/abc/authorize
.
我已经重写了引擎,如下所示
httpd.conf
文件:
RewriteEngine on
RewriteRule "^/test-call/(.*)$" "http://localhost:8082/TestCall/$1"
我可以从chrome的开发者控制台看到调用被正确映射。
http://localhost:8082/TestCall/abc/authorize
但我得到了以下CORS错误:
Access to XMLHttpRequest at 'http://localhost:8082/TestCall/abc/authorize' (redirected from 'http://localhost:8083/test-call/abc/authorize') from origin 'http://localhost:8083' has been blocked by CORS policy: Request header field pragma is not allowed by Access-Control-Allow-Headers in preflight response.
我在我的文档中添加了以下标题
httpd。形态
文件:
Header set Access-Control-Allow-Origin "http://localhost:8083"
Header always set Access-Control-Allow-Headers "Authorization, X-Requested-With, Content-Type, content-type, x-requested-with, Accept, Access-Control-Allow-Origin, Cache-Control"
Header always set Cache-Control "no-cache, no-store, must-revalidate"
Header always set Access-Control-Allow-Methods "GET, POST, DELETE, HEAD, OPTIONS"
Header always set Access-Control-Expose-Headers "Content-Security-Policy, Location"
Header always set Access-Control-Max-Age "3600"
这是一个react应用程序,捆绑包使用上面指定的头正确加载,但对于映射的URL,它根本不起作用。由于CORS错误,它失败了。
我启用了
mod_headers
和
mod_rewrite
.
感谢您的帮助!