如果是宝塔Nginx环境
直接在你网站伪静态 如图设置
第一种:
隐藏内容
location / {
if ( $request_method = ‘OPTIONS’ ) {
add_header access-control-allow-headers range;
add_header access-control-allow-methods GET,POST,HEAD,OPTIONS;
add_header access-control-allow-origin *;
return 200;
}
add_header access-control-allow-origin *;
}
location / {
if ( $request_method = ‘OPTIONS’ ) {
add_header access-control-allow-headers range;
add_header access-control-allow-methods GET,POST,HEAD,OPTIONS;
add_header access-control-allow-origin *;
return 200;
}
add_header access-control-allow-origin *;
}
第二种:
隐藏内容
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’;
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;
}
}
评论(1)
回复解答