vue如何配置反向代理(前后端联调,解决跨域)

vue如何配置反向代理(解决跨域)

1、前后端的计算机连在同一个局域网
2、把config/index.js中的反向代理改一下(找到如下代码,把target改成后端的ip地址和端口号)

proxyTable: {
	'/api': {
		target: 'http://localhost:3000',//需要代理的地址
		changeOrigin: true,
		pathRewrite: {
		 	 '^/api':""
		}
	}
}

猜你喜欢

转载自blog.csdn.net/qq_43923146/article/details/109246610