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", "version": "0.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "API_TARGET=https://odyssey.wancat.cc vite",
"dev:local": "vite",
"build": "vite build", "build": "vite build",
"preview": "vite preview" "preview": "vite preview"
}, },
+5 -4
View File
@@ -7,12 +7,13 @@ export default defineConfig({
server: { server: {
proxy: { proxy: {
'/api': { '/api': {
target: 'http://localhost:3000/api/v1', target: `${process.env.API_TARGET || 'http://localhost:3000'}/api/v1`,
rewrite: (path) => path.replace(/^\/api/, ''), // Optional: remove "/api" prefix from the path changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
}, },
'/socket.io': { '/socket.io': {
target: 'ws://localhost:3000', target: process.env.API_TARGET || 'ws://localhost:3000',
// target: 'wss://odyssey.wancat.cc', changeOrigin: true,
ws: true, ws: true,
}, },
}, },
+1
View File
@@ -12,6 +12,7 @@
], ],
"scripts": { "scripts": {
"app": "yarn workspace app dev", "app": "yarn workspace app dev",
"app:local": "yarn workspace app dev:local",
"server": "yarn workspace server dev", "server": "yarn workspace server dev",
"cli": "yarn workspace client start", "cli": "yarn workspace client start",
"lint": "eslint --ext .js,.vue .", "lint": "eslint --ext .js,.vue .",