跨域代理大坑

mac2026-02-21  11

// 坑:注意 注意 注意 修改完config后一定一定要重启服务 module.exports={ devServer:{ proxy:{ '/Main': { // main这个接口本身就有,所以注释掉pathRewrite路径重写 target: 'https://zhishuapi.aldwx.com', // 遇到 /api 会去请求 https://zhishuapi.aldwx.com地址 changeOrigin: true, // pathRewrite: { '^/api': '' }, }, '/api': { // api这个接口本身没有,为了标识代理,所以用pathRewrite替换为空 target: 'https://www.apiopen.top', // 遇到 /api 会去请求 https://zhishuapi.aldwx.com地址 changeOrigin: true, pathRewrite: { '^/api': '' }, }, } } }
最新回复(0)