nginx如何配置跨域请求?

提问者:帅平 问题分类:运维

nginx如何配置跨域请求?

1 个回答
有个笨蛋住进我心
有个笨蛋住进我心

nginx配置跨域,只需要在nginx的conf里面的location里面配置跨域参数即可,跨域参数是:

add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' *;
add_header 'Access-Control-Allow-Headers' 'Origin,X-Requested-With,Content-Type,Accept,token';

具体配置如下图:

发布于:4个月前 (11-27)
我来回答