+
95
-

nginx如何配置跨域请求?

nginx如何配置跨域请求?我想设置子域名可以跨域

网友回复

+
15
-

只需要在Nginx的配置文件中配置以下参数:

location / { 
	add_header Access-Control-Allow-Origin *;
	add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
	add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';

	if ($request_method = 'OPT...

点击查看剩余70%

我知道答案,我要回答