diff --git a/app/package.json b/app/package.json index de08c19..bd2350a 100644 --- a/app/package.json +++ b/app/package.json @@ -4,7 +4,8 @@ "version": "0.0.0", "type": "module", "scripts": { - "dev": "vite", + "dev": "API_TARGET=https://odyssey.wancat.cc vite", + "dev:local": "vite", "build": "vite build", "preview": "vite preview" }, diff --git a/app/vite.config.js b/app/vite.config.js index c3d6440..2683207 100644 --- a/app/vite.config.js +++ b/app/vite.config.js @@ -7,12 +7,13 @@ export default defineConfig({ server: { proxy: { '/api': { - target: 'http://localhost:3000/api/v1', - rewrite: (path) => path.replace(/^\/api/, ''), // Optional: remove "/api" prefix from the path + target: `${process.env.API_TARGET || 'http://localhost:3000'}/api/v1`, + changeOrigin: true, + rewrite: (path) => path.replace(/^\/api/, ''), }, '/socket.io': { - target: 'ws://localhost:3000', - // target: 'wss://odyssey.wancat.cc', + target: process.env.API_TARGET || 'ws://localhost:3000', + changeOrigin: true, ws: true, }, }, diff --git a/package.json b/package.json index 02f9ac1..6ecf712 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ ], "scripts": { "app": "yarn workspace app dev", + "app:local": "yarn workspace app dev:local", "server": "yarn workspace server dev", "cli": "yarn workspace client start", "lint": "eslint --ext .js,.vue .",