跨域问题

当一个域名从另一个域名调取文件时出现如下

XMLHttpRequest cannot load http://www.xxx.com/header_data.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://shuju.xxx.com' is therefore not allowed access. The response had HTTP status code 404.

解决办法如下:

location / {

...

add_header Access-Control-Allow-Origin *;     #允许所有域名调取,当然这里的'*'号你可以设置指定的域名

...

}

原文地址:https://www.cnblogs.com/zenghui940/p/4738809.html