我的vue端口是8090 后台端口是8080最开始是在vue的proxyTable中配置'/api': { target: 'http://localhost:8080',
changeOrigin: true,
pathRewrite: {
'^/api': 'http://localhost:8080' //路径重写
}
},接口如:/api/system/troubles/login本地可以正常跨域现在想用nginx实现server { listen 1111; server_name localhost; location ^~/api/ { rewrite ^/api/(.*) /$1 break; proxy_pass http://localhost:8080/;
}
}listen写8090会报端口占用,随便写个1111无法跨域报404,还是location错误?应该怎么写
1 回答
largeQ
TA贡献2039条经验 获得超7个赞
都走 nginx 代理才行吧
server { listen 8088; server_name localhost; location / { proxy_pass http://localhost:8090 } location /api/ { proxy_pass http://localhost:8080/; } }
添加回答
举报
0/150
提交
取消