nginx跨域


前端跨域

nginx跨域
location / {
      add_header Access-Control-Allow-Origin *;
      add_header Access-Control-Allow-Credentials true; #允许携带token
      add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
      add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
}


什么是跨域?
浏览器的保护措施,跨域是指一个域下的文档或脚本试图去请求另一个域下的资源,这里跨域是广义的。

广义的跨域:
1.) 资源跳转: A链接、重定向、表单提交
2.) 资源嵌入: