webpack代理的一些问题

代理http

module.exports={
	//...
	devServer:{
		proxy:{
			"/api":{
				target:"http://localhost:3000",
				changeOrigin: true,
				pathRewrite:{
					"^api":""
				}
			}
		}
	}
}

代理https

默认不支持使用无效证书的https后端服务,可以改配置

module.exports={
	//...
	devServer:{
		proxy:{
			"/api":{
				target:"http://localhost:3000",
				changeOrigin: true,
				secure:false,
				pathRewrite:{
					"^api":""
				}
			}
		}
	}
}

猜你喜欢

转载自blog.csdn.net/qq_36893477/article/details/131129008