fix the bugs
This commit is contained in:
parent
047df7e3d2
commit
c50197d3a2
1 changed files with 5 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
export const ENV = {
|
||||
WS_URL: process.env.NEXT_PUBLIC_WS_URL,
|
||||
API_URL: process.env.NEXT_PUBLIC_API_URL,
|
||||
WS_URL: process.env.NEXT_PUBLIC_WS_URL || "ws://localhost:3001",
|
||||
API_URL: process.env.NEXT_PUBLIC_API_URL || "http://localhost:3001/api",
|
||||
} as const;
|
||||
|
||||
export type ENV = typeof ENV;
|
||||
|
@ -9,10 +9,11 @@ export type ENV = typeof ENV;
|
|||
export function assertEnvVariables(ENV: ENV): asserts ENV is Required<ENV> {
|
||||
const missingVariables = Object.entries(ENV).filter(([_, value]) => value === undefined);
|
||||
if (missingVariables.length > 0) {
|
||||
throw new Error(`Missing environment variables: ${missingVariables.map(([key]) => key).join(", ")}`);
|
||||
console.warn(`Warning: Missing environment variables: ${missingVariables.map(([key]) => key).join(", ")}`);
|
||||
console.warn("Using default values for missing variables.");
|
||||
}
|
||||
}
|
||||
|
||||
assertEnvVariables(ENV);
|
||||
|
||||
export const VALIDATED_ENV: Required<ENV> = ENV as Required<ENV>;
|
||||
export const VALIDATED_ENV: Required<ENV> = ENV as Required<ENV>;
|
Loading…
Add table
Reference in a new issue