Client stubs: Env

This commit is contained in:
Enrico Ros
2025-11-22 18:56:45 -08:00
parent 8ada8811bf
commit 90386f5794
2 changed files with 25 additions and 1 deletions
+16
View File
@@ -0,0 +1,16 @@
/**
* Client-side stub for env.server.ts - used by webpack to replace env.server.ts in client bundles
*/
// [server-side] throw immediately if imported
if (typeof window === 'undefined')
throw new Error('[DEV] env.client-mock: client module should never be imported on the server.');
// [client-side] stub exports matching env.server.ts interface
export const env = new Proxy({} as any, {
get(_target, prop) {
throw new Error(`[DEV] env.client-mock: client shall not access server env.${String(prop)}`);
},
});
+9 -1
View File
@@ -1,4 +1,12 @@
// noinspection ES6PreferShortImport - because the build would not find this file with ~/...
/**
* Server-side environment variables centralized access and validation.
* Replaced with env.client-mock.ts on client builds via webpack.
*/
// [server-side] throw immediately if imported on client side
if (typeof window !== 'undefined')
throw new Error('[DEV] env.server: server module should never be imported on the client.');
// noinspection ES6PreferShortImport - because this is included by `next.config.ts` and build would not find this file with ~/...
import { createEnv } from '../modules/3rdparty/t3-env';
import * as z from 'zod/v4';