小工具知识网

当前位置: 首页 > 行业知识 > Proxy error: Could not proxy request 解决方法

行业知识

Proxy error: Could not proxy request 解决方法

2026-11-01 15:37:57 来源:互联网转载

问题本质是代理失败

常见原因

1.后���相应的被代理服务器没有开启

()

2.代理规则写错,前后端部署的域名应一致;

3.没有把vue.config.js中的 before: require('./mock/mock-server.js'),注释掉,导致走代理前走了mockjs

()

4.URL前面不完整,没有http://

5.dns解析有问题,可以把target:'http://xxx' 里面的网址换成ip

6.npm install portfinder@1.0.21 安装这个低版本的模块就可以了

7.127.0.0.1偶尔不行,直接使用localhost

8.请求是否超出代理timeout,代理失败

9.node服务运行在localhost:a端口,vue运行在localhost:b端口,不同端口存在跨域问题。

需要在vue.config.js中添加

proxy:{    '/api2':{        target:'http://localhost:3000',         changeOrigin:true,     }}

*.更改配置后,要重启vue项目

上一篇:Monster发音攻略,轻松掌握正确读音!

下一篇:联想服务器联网怎么设置?