- There was an error rendering this page. Check the browser console for more information.
+
+ There was an error rendering this page. Check the browser console for
+ more information.
+
)
}
diff --git a/waspc/data/Generator/templates/sdk/wasp/client/config.ts b/waspc/data/Generator/templates/sdk/wasp/client/config.ts
index 39b620af01..fff77cb01c 100644
--- a/waspc/data/Generator/templates/sdk/wasp/client/config.ts
+++ b/waspc/data/Generator/templates/sdk/wasp/client/config.ts
@@ -1,7 +1,7 @@
-{{={= =}=}}
import { stripTrailingSlash } from '../universal/url.js'
+import { env } from './env.js'
-const apiUrl = stripTrailingSlash(import.meta.env.REACT_APP_API_URL) || '{= defaultServerUrl =}';
+const apiUrl = stripTrailingSlash(env.REACT_APP_API_URL)
// PUBLIC API
export type ClientConfig = {
diff --git a/waspc/data/Generator/templates/sdk/wasp/client/env.ts b/waspc/data/Generator/templates/sdk/wasp/client/env.ts
new file mode 100644
index 0000000000..fe8002c575
--- /dev/null
+++ b/waspc/data/Generator/templates/sdk/wasp/client/env.ts
@@ -0,0 +1,15 @@
+{{={= =}=}}
+import * as z from 'zod'
+
+import { ensureEnvSchema } from '../env/index.js'
+
+const clientEnvSchema = z.object({
+ REACT_APP_API_URL: z
+ .string({
+ required_error: 'REACT_APP_API_URL is required',
+ })
+ .default('{= defaultServerUrl =}')
+})
+
+// PUBLIC API
+export const env = ensureEnvSchema(import.meta.env, clientEnvSchema)
diff --git a/waspc/data/Generator/templates/sdk/wasp/client/index.ts b/waspc/data/Generator/templates/sdk/wasp/client/index.ts
index cfce564c4d..859f8656b6 100644
--- a/waspc/data/Generator/templates/sdk/wasp/client/index.ts
+++ b/waspc/data/Generator/templates/sdk/wasp/client/index.ts
@@ -11,4 +11,7 @@ export enum HttpMethod {
export type Route = { method: HttpMethod; path: string }
// PUBLIC API
-export { config, ClientConfig } from './config'
+export { config, ClientConfig } from './config.js'
+
+// PUBLIC API
+export { env } from './env.js'
diff --git a/waspc/data/Generator/templates/sdk/wasp/env/index.ts b/waspc/data/Generator/templates/sdk/wasp/env/index.ts
new file mode 100644
index 0000000000..a5bc334754
--- /dev/null
+++ b/waspc/data/Generator/templates/sdk/wasp/env/index.ts
@@ -0,0 +1,25 @@
+import * as z from 'zod'
+
+const redColor = '\x1b[31m'
+
+export function ensureEnvSchema