关于vue 使用axios(已配置好代理等)请求接口还是报404问题

proxy: {
			'/blog': {
				target: 'http://localhost:8099', //API服务器的地址
				ws: true, //代理websockets
				changeOrigin: true, // 是否跨域,虚拟的站点需要更管origin
				pathRewrite: {
					// '^/api'是一个正则表达式,表示要匹配请求的url中,全部'http://localhost:8081/api' 转接为 http://localhost:8081/
					'^/blog': '',
				}
			},
			'/music':{
				target: 'http://cloud-music.pl-fe.cn',
				ws: true,
				changeOrigin: true,
				pathRewrite: {
					'^/music':'',
				}
			},
			'/free':{
				target:'https://v.api.aa1.cn/api',
				//ws:true,
				changeOrigin:true,
				pathRewrite:{
					'^/free':'',
				}
			},
			'/yk':{
				target:'https://api.iyk0.com',
				changeOrigin:true,
				pathRewrite:{
					'^/yk':'',
				}
			},
			'/mxg':{
				target:'https://api.muxiaoguo.cn/api',
				changeOrigin:true,
				pathRewrite:{
					'^/mxg':'',
				}
			}

 问题解决:axios的请求url,不能包含有其他代理的名字,比如说我调用第一个代理接口blog,路径中就不能有其他的代理名称(不能含有/yk/或者/free/或者/music/)

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值