在指定的主机location 下添加以下语句便可;
如:
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;
}
}
原文地址:https://blog.51cto.com/jxlwc/2363517
时间: 2024-10-15 14:49:46