nginx 实现跨域访问

可以在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;

 }

相关推荐