nginx跨域

在nginx对应项目的conf配置文件中修改:

location / {
    # 跨域
    add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Methods 'GET, POST, 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,Authorization';
    if ($request_method = 'OPTIONS') {
        return 204;
    }
}

 

posted @ 2021-01-05 15:21  动灵  阅读(71)  评论(0编辑  收藏  举报