blank
blank
发布于 2019-12-13 / 547 阅读 / 0 评论 / 0 点赞

使用 nginx 代理解决跨域请求问题

注意 localhost 后面的 / 不能省略
proxy_pass 请求到需要跨域的服务器即可

    # Avoid CORS and reverse proxy settings
    location /spweb/ {
        proxy_http_version 1.1;
        proxy_pass https://xx/;

        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Methods "POST, GET, OPTIONS";
        add_header Access-Control-Allow-Headers "Origin, Authorization, Accept";
        add_header Access-Control-Allow-Credentials true;
    }

评论