fix:跨域配置

This commit is contained in:
talktao 2022-09-29 15:17:41 +08:00
parent 9a0e5b3c88
commit a995aff153

View File

@ -28,16 +28,15 @@ export default defineConfig(({ command, mode }) => {
}),
],
// 跨域代理
server: {
host: '0.0.0.0',
proxy: {
//这里是通过请求/api 来转发到 https://api.pingping6.com/
//假如你要请求https://api.*.com/a/a
//那么axios的url可以配置为 /api/a/a
'/api': ''
'/api': {
target: 'https://api.inews.qq.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '') // 将匹配到的api替换成''
}
}
}
};