在网站的配置文件中的第一个location前加入下面这段,宝塔中add_header加到location一直不生效不知为什么,而且add_header放在if中也报错
set $dom "no";
if ($http_origin ~* \.csdn\.net|\.0\.1){
set $dom $http_origin;
}
add_header Access-Control-Allow-Origin $dom;
add_header Access-Control-Allow-Methods "GET,POST,PUT,DELETE,OPTIONS";
add_header Access-Control-Allow-Headers "*";
if ($request_method = 'OPTIONS'){
return 204;
}