diff --git a/vite.config.ts b/vite.config.ts index 3d1fb8b..f2c6f20 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -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替换成'' + } } } };