nginx 跨域

墨氺 2018-12-03

if ($request_method = 'OPTIONS') {

add_header 'Access-Control-Allow-Origin' '*';

add_header 'Access-Control-Allow-Credentials' 'true';

add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

add_header 'Access-Control-Max-Age' 1728000;

add_header 'Access-Control-Allow-Headers' 'Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Accept';

add_header 'Content-Type' 'application/json';

add_header 'Content-Length' 0;

return 204;

   }

if ($request_method = 'POST') {

add_header 'Access-Control-Allow-Origin' '*';

add_header 'Access-Control-Allow-Credentials' 'true';

add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

add_header 'Access-Control-Allow-Headers' 'Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Accept';

}

if ($request_method = 'GET') {

add_header 'Access-Control-Allow-Origin' '*';

add_header 'Access-Control-Allow-Credentials' 'true';

add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';

add_header 'Access-Control-Allow-Headers' 'Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Accept';

}

proxy_pass http://192.168.201.54:8323/wind/query_wind_resource_data;

headers.append("Content-Type", "application/json;charset=UTF-8");
let init: RequestInit = {
  method: "POST",
mode: "cors",
headers: headers,
body: JSON.stringify({
})};
fetch(RouterConfig.rtrvMeteorologicForecastTime, init)

相关推荐

lwplvx / 0评论 2020-11-22
岁月如歌 / 0评论 2020-07-21