mirror of
https://github.com/talktao/Vue3-Vite-Vant-TS-H5.git
synced 2025-05-21 22:02:24 +08:00
fix:跨域配置
This commit is contained in:
parent
9a0e5b3c88
commit
a995aff153
@ -28,16 +28,15 @@ export default defineConfig(({ command, mode }) => {
|
|||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 跨域代理
|
// 跨域代理
|
||||||
server: {
|
server: {
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
proxy: {
|
proxy: {
|
||||||
//这里是通过请求/api 来转发到 https://api.pingping6.com/
|
'/api': {
|
||||||
//假如你要请求https://api.*.com/a/a
|
target: 'https://api.inews.qq.com',
|
||||||
//那么axios的url,可以配置为 /api/a/a
|
changeOrigin: true,
|
||||||
'/api': ''
|
rewrite: (path) => path.replace(/^\/api/, '') // 将匹配到的api替换成''
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user