Nginx 设置前后端跨域

server

........

    add_header Access-Control-Allow-Origin $http_origin;
    add_header Access-Control-Allow-Methods GET,POST,PUT,OPTIONS,DELETE,PATCH;
    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,Content-Range,Range,userId,token,vcode,channelcode,Accept,adminToken,admintoken;
    add_header Access-Control-Max-Age 1728000;

    if ($request_method = OPTIONS ) { return 204; }

 

........

 

Nginx 设置前后端跨域

上一篇:ARC122 B - Insurance(数学)


下一篇:二叉树遍历