fix: use environment to select API_ENDPOINT

This commit is contained in:
wancat committed 2023-08-21 20:59:35 +08:00
1 parent c248004484
commit d86aa5bcc1
3 files changed
+8 -5

No files matched your search

+2 -1
View File
@@ -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"
},
+5 -4
View File
@@ -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,
},
},
+1
View File
@@ -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 .",