Live2D

Nginx 解决跨域问题

打开 nginx.conflocation下加入以下内容

location / {  
    add_header 'Access-Control-Allow-Origin' '*' always;
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Methods' 'GET, POST, PATCH, DELETE, PUT, 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, X-Custom-Header, Access-Control-Expose-Headers, Token, Authorization';
    add_header 'Access-Control-Allow-Headers'  '*';
    add_header 'Access-Control-Max-Age' 1728000;
  #预检请求
    if ($request_method = 'OPTIONS') {
        return 204;
    }
} 
posted @ 2022-03-14 16:07  没有梦想的java菜鸟  阅读(1423)  评论(0编辑  收藏  举报