美文网首页工作生活
nginx配置跨域cors配置

nginx配置跨域cors配置

作者: 雁南天todo | 来源:发表于2019-07-03 16:28 被阅读0次

    vhost配置

    location / {
            add_header Access-Control-Allow-Origin $http_origin;
            add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
            add_header Access-Control-Allow-Credentials true;
            add_header Access-Control-Allow-Headers DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type;
            add_header Access-Control-Max-Age 1728000;
            if ($request_method = OPTIONS) {
                  add_header Access-Control-Allow-Origin $http_origin;
                  add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
                  add_header Access-Control-Allow-Credentials true;
                  add_header Access-Control-Allow-Headers DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type;
                  add_header Access-Control-Max-Age 1728000;
                  return 204;
             }
        }
    

    相关文章

      网友评论

        本文标题:nginx配置跨域cors配置

        本文链接:https://www.haomeiwen.com/subject/vzhchctx.html