Nginx 跨站访问

跨站访问

对于浏览器来说一般默认是禁止的

为什么浏览器进制跨域访问

不安全,容易出现CSRF攻击

Ngin怎么做

syntax:  add_header name value[always];
default:  -
context:  http,server,location,if in location

Access-Control-Allow-Origin

主要在配置文件中进行配置
add_header Access-Control-Allow-Origin http://www.xxx.com;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;

原文地址:https://www.cnblogs.com/Mrchengs/p/11940423.html