fix: resolve production crash in api-client.ts and frontend.tsx by using env utility
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { edenTreaty } from "@elysiajs/eden";
|
||||
import type { ApiApp } from "../index";
|
||||
import { VITE_PUBLIC_URL } from "./env";
|
||||
|
||||
const baseUrl =
|
||||
import.meta.env.VITE_PUBLIC_URL ||
|
||||
VITE_PUBLIC_URL ||
|
||||
(typeof window !== "undefined"
|
||||
? window.location.origin
|
||||
: "http://localhost:3000");
|
||||
|
||||
@@ -21,3 +21,11 @@ export const getEnv = (key: string, defaultValue = ""): string => {
|
||||
};
|
||||
|
||||
export const VITE_PUBLIC_URL = getEnv("VITE_PUBLIC_URL", "http://localhost:3000");
|
||||
|
||||
export const IS_DEV = (() => {
|
||||
try {
|
||||
return typeof import.meta.env !== "undefined" && import.meta.env.DEV;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user