nginx跨域

在nginx.conf中配置
http {
……
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
……
}
这样就可以实现GET,POST,OPTIONS的跨域请求的支持
也可以 add_header Access-Control-Allow-Origin http://test.51testing.com; –指定允许的url;

配置项详细解释:w3c-Cross-Origin Resource Sharing
感谢博主:

文章来源:http://www.51testing.com/html/96/215196-829360.html

猜你喜欢

转载自blog.csdn.net/qq_31001889/article/details/80513635