nginx跨域问题记录


现象:
访问 toolbox.chinasoft.com 提示如下:
Access to Font at 'https://images.chinasoft.com/static-toolbox/style/fonts/global_iconfont.woff?iv41ks' from origin 'https://toolbox.chinasoft.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin'
header is present on the requested resource. Origin 'https://toolbox.chinasoft.com' is therefore not allowed access.


解决:
1.在toolbox.chinasoft.com.conf中添加跨域的配置,问题依旧
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, PUT, POST, DELETE, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Content-Type,*';

2.多次配置无效,于是在images.chinasoft.com中也配置可以跨域,问题解决

原文地址:https://www.cnblogs.com/reblue520/p/10338216.html