nginx配置允许跨域请求

时间:2018-05-04 10:20:32   收藏:0   阅读:817
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://xxx.com; --指定允许的url;

配置项详细解释:w3c-Cross-Origin Resource Sharing

原文:http://blog.51cto.com/haoyonghui/2112513

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!