(CORS) Nginx配置跨域

2022-11-05 11:37:33 浏览数 (1)

网站配置文件server 添加以下即可

代码语言:javascript复制
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 = 'OPTIONS') {
    return 204;
}
} 

0 人点赞