@@ -18,13 +18,17 @@ import vercelConfig from './vercel.json'
1818
1919const KiB = 1024
2020
21- const ApiMode = z . enum ( [ 'msw' , 'dogfood' , 'nexus' ] )
21+ const ApiMode = z . enum ( [ 'msw' , 'remote' , 'nexus' ] )
22+
23+ function bail ( msg : string ) : never {
24+ console . error ( msg )
25+ process . exit ( 1 )
26+ }
2227
2328const apiModeResult = ApiMode . default ( 'nexus' ) . safeParse ( process . env . API_MODE )
2429if ( ! apiModeResult . success ) {
2530 const options = ApiMode . options . join ( ', ' )
26- console . error ( `Error: API_MODE must be one of: [${ options } ]. If unset, default is "msw".` )
27- process . exit ( 1 )
31+ bail ( `Error: API_MODE must be one of: [${ options } ]. If unset, default is "msw".` )
2832}
2933/**
3034 * What API are we talking to? Only relevant in development mode.
@@ -35,8 +39,11 @@ if (!apiModeResult.success) {
3539 */
3640const apiMode = apiModeResult . data
3741
38- // if you want a different host you can override it with EXT_HOST
39- const DOGFOOD_HOST = process . env . EXT_HOST || 'oxide.sys.rack2.eng.oxide.computer'
42+ if ( apiMode === 'remote' && ! process . env . EXT_HOST ) {
43+ bail ( `Error: EXT_HOST is required when API_MODE=remote. See package.json for examples.` )
44+ }
45+
46+ const EXT_HOST = process . env . EXT_HOST
4047
4148const previewAnalyticsTag = {
4249 injectTo : 'head' as const ,
@@ -126,7 +133,7 @@ export default defineConfig(({ mode }) => ({
126133 } ,
127134 } ) ,
128135 react ( ) ,
129- apiMode === 'dogfood ' && basicSsl ( ) ,
136+ apiMode === 'remote ' && basicSsl ( ) ,
130137 ] ,
131138 html : {
132139 // don't include a placeholder nonce in production.
@@ -139,8 +146,7 @@ export default defineConfig(({ mode }) => ({
139146 // these only get hit when MSW doesn't intercept the request
140147 proxy : {
141148 '/v1' : {
142- target :
143- apiMode === 'dogfood' ? `https://${ DOGFOOD_HOST } ` : 'http://localhost:12220' ,
149+ target : apiMode === 'remote' ? `https://${ EXT_HOST } ` : 'http://localhost:12220' ,
144150 changeOrigin : true ,
145151 } ,
146152 } ,
0 commit comments