File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 1- type AppConfig = {
1+ export type AppConfig = {
22 CONFIDENTIAL_ASSET_MODULE_ADDR : string ;
33 /**
44 * This is the asset the user deals with in the app. For the demo they only use a
@@ -58,3 +58,11 @@ export const appConfig: AppConfig = {
5858
5959 FORCE_MAINTENANCE_PAGE : process . env . FORCE_MAINTENANCE_PAGE === 'true' ,
6060} ;
61+
62+ // Iterate through the config and ensure nothing is undefined. This check runs client
63+ // side, so we only check NEXT_PUBLIC_ variables. We check everything in middleware.ts.
64+ for ( const key in appConfig ) {
65+ if ( key . startsWith ( 'NEXT_PUBLIC_' ) && appConfig [ key as keyof AppConfig ] === undefined ) {
66+ throw new Error ( `Required environment variable ${ key } is not set.` ) ;
67+ }
68+ }
Original file line number Diff line number Diff line change 11import { createMiddleware , type MiddlewareFunctionProps } from '@rescale/nemo' ;
22import { NextResponse } from 'next/server' ;
33
4- import { appConfig } from './config' ;
4+ import { AppConfig , appConfig } from './config' ;
5+
6+ // Iterate through the config and ensure nothing is undefined.
7+ for ( const key in appConfig ) {
8+ if ( appConfig [ key as keyof AppConfig ] === undefined ) {
9+ throw new Error ( `Required environment variable ${ key } is not set.` ) ;
10+ }
11+ }
512
613async function shouldShowMaintenancePage ( ) {
714 if ( appConfig . FORCE_MAINTENANCE_PAGE ) {
You can’t perform that action at this time.
0 commit comments