Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Use VITE_BACKEND as the backendURL if specified. Otherwise, just use the current host

天舟0ded9815eca7
diff --git a/frontend/.env.demo b/frontend/.env.demo
index b45016c4ab..995fca4af2 100644
--- a/frontend/.env.demo
+++ b/frontend/.env.demo
@@ -1,2 +1 @@
-NODE_ENV=production
-VITE_BACKEND=http://localhost:8080
\ No newline at end of file
+NODE_ENV=production
\ No newline at end of file
diff --git a/frontend/.env.release b/frontend/.env.release
new file mode 100644
index 0000000000..c74b12421c
--- /dev/null
+++ b/frontend/.env.release
@@ -0,0 +1 @@
+NODE_ENV=release
\ No newline at end of file
diff --git a/frontend/package.json b/frontend/package.json
index 51bfae68a5..3dba9f6cdf 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -4,7 +4,7 @@
"license": "AGPL-3.0-only",
"scripts": {
"dev": "vite --mode dev",
- "package": "vite build --outDir=../backend/server/dist --emptyOutDir",
+ "release": "vite build --mode release --outDir=../backend/server/dist --emptyOutDir",
"demo": "vite build --mode demo --outDir=dist"
},
"dependencies": {
diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts
index c56e98b073..4a6671946f 100644
--- a/frontend/src/utils/util.ts
+++ b/frontend/src/utils/util.ts
@@ -12,8 +12,14 @@ export function isRelease(): boolean {
return import.meta.env.PROD && !isDemo();
}
+// Use VITE_BACKEND as the backendURL if specified. Otherwise, just use the current host
+// For dev environment, we usually set VITE_BACKEND to point to different backend.
+// For production environment, we won't set VITE_BACKEND because we bundle frontend/backend as a monolithic.
export function backendURL(): string {
- return import.meta.env.VITE_BACKEND as string;
+ if (import.meta.env.VITE_BACKEND) {
+ return import.meta.env.VITE_BACKEND as string;
+ }
+ return window.location.origin;
}
export function humanizeTs(ts: number): string {