
在nginx配置里面添加add_header如下:
add_header 'Access-Control-Allow-Origin' '*';
#add_header 'Access-Control-Allow-Origin' 'http://localhost:8080' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'X-Requested-With, Content-Type, Authorization' always;
对于java接口跨越则改成这样配置:
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, Authorization, Authorization-Front' always;
本文详细介绍了如何在Nginx配置中添加CORS头,包括允许来自任何源的请求、特定域名以及支持的HTTP方法和头部字段。
171万+

被折叠的 条评论
为什么被折叠?



