配置Nginx后出现No ‘Access-Control-Allow-Origin‘ header is present on the requested resource
开发前后端分离项目时配置Nginx出现此跨域问题解决方法在nginx.conf配置文件中加入以下配置,即可解决问题location / {add_header Access-Control-Allow-Origin *;add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";a
·
开发前后端分离项目时配置Nginx出现此跨域问题
解决方法
在nginx.conf配置文件中加入以下配置,然后重启Nginx服务,即可解决问题
location / {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
}
更多推荐
已为社区贡献1条内容
所有评论(0)