From 56f94f384db64d5d4160f9ef28adb03e04fb991e Mon Sep 17 00:00:00 2001 From: cat_shark <1716967236@qq.com> Date: Sun, 12 Apr 2026 10:37:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE(=E5=BC=80=E5=8F=91=E7=8E=AF?= =?UTF-8?q?=E5=A2=83):=20=E5=A2=9E=E5=8A=A0Vite=E4=BB=A3=E7=90=86=E4=BB=A5?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=9C=AC=E5=9C=B0CORS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- vite.config.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.env.development b/.env.development index 66db44e..f5603e3 100644 --- a/.env.development +++ b/.env.development @@ -1 +1 @@ -VITE_BASE_URL = 'http://localhost:5157' \ No newline at end of file +VITE_BASE_URL=/api diff --git a/vite.config.ts b/vite.config.ts index 2acf118..68aece1 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -15,6 +15,13 @@ export default defineConfig({ }, server: { host: '0.0.0.0', - port: 5158 + port: 5158, + proxy: { + "/api": { + target: "http://localhost:5157", + changeOrigin: true, + rewrite: (path) => path.replace(/^\/api/, ""), + }, + }, } })