vue的端口是8080,nginx按理来说是监听8080的但是请求的接口是404。
下面是nginx的配置:
server {
listen 8080;
server_name localhost;
location / {
add_header Access-Control-Allow-Origin *;
root html;
index index.html index.htm;
}
location /api {
proxy_pass https://www.sxqcwx.com;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
我的请求
this.postAxios("/api/findRegion2", {}, res => {
console.log(res);
});
在Vue中这样是可以请求成功的
proxyTable: {
// '/api/**': {
// target: 'https://www.sxqcwx.com',
// secure: false,
// changeOrigin: true,
// }
}