1.vue中的config配置
const baseUrl="http://192.168.10.206:8092"
const VUE_APP_BASE_API = '/api'
devServer: {
disableHostCheck: true,
port:8082,
proxy: {
[process.env.VUE_APP_BASE_API]: {
target: baseUrl,
changeOrigin: true,
pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: ''
}
},
},
},
2.nginx的nginx.conf配置
location / {
root html;
index index.html index.htm index.php;
}
location /api/ {
rewrite ^/api/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8092; #机器ip
}