最近在使用nginx代理时遇到跨域问题,现整理解决方案如下
The ‘Access-Control-Allow-Origin’ header contains multiple values
‘********’, but only one is allowed.
1 报错信息
2解决方案
在nginx的配置文件中添加下面这几行
# 允许请求地址跨域 * 做为通配符
add_header Access-Control-Allow-Origin *;
# 允许跨域的请求方法
add_header Access-Control-Allow-Methods 'GET,POST,options';
# 请求头
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';