vuecli的配置文件
module.exports = { devServer: { proxy: { //配置跨域 "/api": { target: "http://axios.qitianlie.com/", //这里后台的地址模拟的;应该填写你们真实的后台接口 // target: "http://localhost:8088/", ws: true, changOrigin: true, //允许跨域 pathRewrite: { "^/api": "" //请求的时候使用这个api就可以 } } } } };
在宝塔面板中网站设置中选择配置文件在server中添加
location /api {
proxy_pass http://axios.qitianlie.com/;
}
在vue和ngnix中的后端地址要对应否则会出错