配置 Nginx 进行对应转发:
listen 80;
server_name ${product.xxx.xxx.com}; //nginx运行域名
location / {
proxy_pass http://localhost:8081; //只想vue项目
proxy_set_header Host $host;
}
location /api {
proxy_read_timeout 200s;
proxy_next_upstream off;
proxy_pass http://test1www.ehbpay.com/api/; //指向线上域名
proxy_set_header Host $host;
}
配置 vue.config.js 以免出现 Invalid Host header 报错:
{devServer: { disableHostCheck: true }}