Nginx跨域报错

把大文件换了个地方放,居然跨域报错

虽然可以代理,但还是想直接省事
在指定网站的配置文件里加以下选项

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;
    }
}

方法来自:Augen Developer

标签: Nginx, 跨域, No 'Access-Control-Allow-Origin' header