Skip to content

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

Move .env files to the root directory in order for vite to actually pickup

天舟c125aeaecd17
diff --git a/frontend/.env.demo b/frontend/.env.demo
new file mode 100644
index 0000000000..b45016c4ab
--- /dev/null
+++ b/frontend/.env.demo
@@ -0,0 +1,2 @@
+NODE_ENV=production
+VITE_BACKEND=http://localhost:8080
\ No newline at end of file
diff --git a/frontend/.env.dev b/frontend/.env.dev
new file mode 100644
index 0000000000..d7fba3f837
--- /dev/null
+++ b/frontend/.env.dev
@@ -0,0 +1,2 @@
+NODE_ENV=development
+VITE_BACKEND=http://localhost:8080
\ No newline at end of file
diff --git a/frontend/src/.env.demo b/frontend/src/.env.demo
deleted file mode 100644
index 995fca4af2..0000000000
--- a/frontend/src/.env.demo
+++ /dev/null
@@ -1 +0,0 @@
-NODE_ENV=production
\ No newline at end of file
diff --git a/frontend/src/.env.dev b/frontend/src/.env.dev
deleted file mode 100644
index 083c815f94..0000000000
--- a/frontend/src/.env.dev
+++ /dev/null
@@ -1 +0,0 @@
-NODE_ENV=development
\ No newline at end of file
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index 94dd57382b..b164b79434 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -39,6 +39,7 @@ import {
isDev,
isDemo,
isRelease,
+ backend,
humanizeTs,
sizeToFit,
urlfy,
@@ -76,8 +77,10 @@ app.config.globalProperties.dataSourceSlug = dataSourceSlug;
registerStoreWithRoleUtil(store);
-console.debug("dev: ", isDev());
-console.debug("mode: ", import.meta.env.MODE);
+console.debug("dev:", isDev());
+console.debug("demo:", isDemo());
+console.debug("release:", isRelease());
+console.debug("backend:", backend());
axios.defaults.timeout = 3000;
axios.interceptors.request.use((request) => {
diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.ts
index abc07d395e..fb9005a8e9 100644
--- a/frontend/src/utils/util.ts
+++ b/frontend/src/utils/util.ts
@@ -1,18 +1,22 @@
import moment from "moment";
-export function isDev() {
+export function isDev(): boolean {
return import.meta.env.DEV;
}
-export function isDemo() {
+export function isDemo(): boolean {
return import.meta.env.MODE === "demo";
}
-export function isRelease() {
+export function isRelease(): boolean {
return import.meta.env.PROD && !isDemo();
}
-export function humanizeTs(ts: number) {
+export function backend(): string {
+ return import.meta.env.VITE_BACKEND as string;
+}
+
+export function humanizeTs(ts: number): string {
const time = moment.utc(ts * 1000);
if (moment().year() == time.year()) {
if (moment().dayOfYear() == time.dayOfYear()) {
@@ -26,7 +30,7 @@ export function humanizeTs(ts: number) {
return time.local().format("MMM D YYYY");
}
-export function bytesToString(size: number) {
+export function bytesToString(size: number): string {
const unitList = ["B", "KB", "MB", "GB", "TB"];
let i = 0;
for (i = 0; i < unitList.length; i++) {
@@ -38,7 +42,7 @@ export function bytesToString(size: number) {
return size.toString() + " " + unitList[i];
}
-export function urlfy(str: string) {
+export function urlfy(str: string): string {
let result = str.trim();
if (result.search(/^http[s]?\:\/\//) == -1) {
result = "http://" + result;
@@ -46,7 +50,7 @@ export function urlfy(str: string) {
return result;
}
-export function isURL(str: string) {
+export function isURL(str: string): boolean {
let url;
try {