项目部署在 nginx 下,访问时报跨域问题
1 错误信息
No 'Access-Control-Allow-Origin' header is present on the requested resource.
2 解决方法
在 nginx.conf 配置文件 http 下增加以下代码
http {
...
#support cross domain access
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
...
}