我的vue端口是8090 后臺(tái)端口是8080最開(kāi)始是在vue的proxyTable中配置'/api': { target: 'http://localhost:8080',
changeOrigin: true,
pathRewrite: {
'^/api': 'http://localhost:8080' //路徑重寫
}
},接口如:/api/system/troubles/login本地可以正??缬颥F(xiàn)在想用nginx實(shí)現(xiàn)server { listen 1111; server_name localhost; location ^~/api/ { rewrite ^/api/(.*) /$1 break; proxy_pass http://localhost:8080/;
}
}listen寫8090會(huì)報(bào)端口占用,隨便寫個(gè)1111無(wú)法跨域報(bào)404,還是location錯(cuò)誤?應(yīng)該怎么寫
1 回答

largeQ
TA貢獻(xiàn)2039條經(jīng)驗(yàn) 獲得超8個(gè)贊
都走 nginx 代理才行吧
server { listen 8088; server_name localhost; location / { proxy_pass http://localhost:8090 } location /api/ { proxy_pass http://localhost:8080/; } }
添加回答
舉報(bào)
0/150
提交
取消