admin管理员组

文章数量:1794759

Nginx解决跨域问题No ‘Access

Nginx解决跨域问题No ‘Access

浏览器控制台报错

Access to XMLHttpRequest at ‘www.aaa’ from Origin ‘www.bbb’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

解决办法

使用Nginx在server块下或location块下为请求添加请求头都可以解决跨域问题。

add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET,POST,DELETE'; add_header 'Access-Control-Allow-Header' 'Content-Type,*';

本文标签: nginxAccess