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

 

........

 

posted @ 2021-08-03 18:22  walkersss  阅读(189)  评论(0编辑  收藏  举报