Every day is wonderful

分享与创新 并大胆的去尝试新鲜事物。。。。

BT面板的NGINX解决CORS跨域问题

 # #设置跨域配置 Start
        set $cors_origin "";
        if ($http_origin ~* "^http://xxx.xx.com$"){
                set $cors_origin $http_origin;
        }

        add_header Access-Control-Allow-Origin $cors_origin always; 
        add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS always;
        add_header Access-Control-Allow-Credentials true always;
        add_header Access-Control-Allow-Headers DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,x-auth-token always;
        add_header Access-Control-Max-Age 1728000 always;

        # 预检请求处理
        if ($request_method = OPTIONS) {
                return 204;
        }
        # #设置跨域配置 End
点赞

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注