File tree 3 files changed +24
-17
lines changed
3 files changed +24
-17
lines changed Original file line number Diff line number Diff line change 1
- import '@/lib/env.server' // startup env var check
2
-
3
1
import './globals.css'
4
2
import { Inter } from 'next/font/google'
5
3
import { DM_Sans } from 'next/font/google'
Original file line number Diff line number Diff line change
1
+ import { init } from '@/lib/env.server' // startup env var check
2
+
3
+ export function register ( ) {
4
+ if ( typeof window === "undefined" ) {
5
+ init ( )
6
+ }
7
+ }
Original file line number Diff line number Diff line change @@ -12,20 +12,22 @@ declare global {
12
12
}
13
13
}
14
14
15
- try {
16
- zodEnv . parse ( process . env )
17
- } catch ( err ) {
18
- if ( err instanceof z . ZodError ) {
19
- const { fieldErrors } = err . flatten ( )
20
- const errorMessage = Object . entries ( fieldErrors )
21
- . map ( ( [ field , errors ] ) =>
22
- errors ? `${ field } : ${ errors . join ( ", " ) } ` : field ,
15
+ export function init ( ) {
16
+ try {
17
+ zodEnv . parse ( process . env )
18
+ } catch ( err ) {
19
+ if ( err instanceof z . ZodError ) {
20
+ const { fieldErrors } = err . flatten ( )
21
+ const errorMessage = Object . entries ( fieldErrors )
22
+ . map ( ( [ field , errors ] ) =>
23
+ errors ? `${ field } : ${ errors . join ( ", " ) } ` : field ,
24
+ )
25
+ . join ( "\n " )
26
+
27
+ console . error (
28
+ `Missing environment variables:\n ${ errorMessage } ` ,
23
29
)
24
- . join ( "\n " )
25
-
26
- console . error (
27
- `Missing environment variables:\n ${ errorMessage } ` ,
28
- )
29
- process . exit ( 1 )
30
+ process . exit ( 1 )
31
+ }
30
32
}
31
- }
33
+ }
You can’t perform that action at this time.
0 commit comments