nginx 实现跨域访问

zongyuewang 2019-08-28

可以在server模块加上如下代码

add_header Access-Control-Allow-Origin *;  

add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, If-Modified-Since";      

add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";        

 if ($request_method = 'OPTIONS') {

              return 204;

 }

相关推荐

lwplvx / 0评论 2020-11-22
岁月如歌 / 0评论 2020-07-21