Nginx允许跨域访问的配置问题

Nginx允许跨域访问的配置问题

蓝科迪梦
2022-10-21 / 0 评论 / 206 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2022年10月21日,已超过552天没有更新,若内容或图片失效,请留言反馈。
跨域问题:

has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://dev2.lystrong.cn' is therefore not allowed access.



为跨域访问问题,可以在静态资源服务器A 配置允许跨域请求,nginx在配置中对应的location下添加上如下的设置:

add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';


重启nginx  
0

评论

博主关闭了所有页面的评论