Skip to content
GitHub

跨域配置

修改配置如下:

location /api {
 	set $cors '';
  if ($http_origin ~* (htt(p|ps)?://.*\.aliwork\.com$)) {
    set $cors $http_origin;
  }
  add_header Access-Control-Allow-Origin '$cors';
  add_header Access-Control-Allow-Methods *;
  add_header Access-Control-Allow-Credentials true;
  add_header Access-Control-Allow-Headers *;
}

注:nginx设置跨域后,程序不能设置跨域配置,会导致双重设置。