前端nginx代理配置,并跳转接口,解决跨域问题
server { listen 1888; server_name localhost; root project/dist; index index.html index.htm; location /api { rewrite ^.+api/?(.*)$ /$1 break; proxy_pass http://172.16.10.202:8888/; #node api server 即需要代理的IP地址 proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location ~* .*\.gz$ { add_header Content-Encoding gzip; } } 来源: oschina 链接: https://my.oschina.net/sundasheng44/blog/4882045