跨域问题在nginx 上做处理

可以application 处理 也可以在nginx 上处理

nginx

server {
        listen       80;
        server_name  localhost;
        location  / {
            add_header Access-Control-Allow-Origin 'http://localhost:8080' always;
            add_header Access-Control-Allow-Headers '*';
            add_header Access-Control-Allow-Methods '*';
            add_header Access-Control-Allow-Credentials 'true';
            if ($request_method = 'OPTIONS') {
                return 204;
            }
            proxy_pass  http://localhost:9000; 
        }
    }
posted @ 2023-06-08 09:01  vx_guanchaoguo0  阅读(17)  评论(0编辑  收藏  举报