nginx跨域问题记录

时间:2023-03-08 15:51:50

现象:
访问 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中也配置可以跨域,问题解决