@@ -18,13 +18,17 @@ import vercelConfig from './vercel.json'
18
18
19
19
const KiB = 1024
20
20
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
+ }
22
27
23
28
const apiModeResult = ApiMode . default ( 'nexus' ) . safeParse ( process . env . API_MODE )
24
29
if ( ! apiModeResult . success ) {
25
30
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".` )
28
32
}
29
33
/**
30
34
* What API are we talking to? Only relevant in development mode.
@@ -35,8 +39,11 @@ if (!apiModeResult.success) {
35
39
*/
36
40
const apiMode = apiModeResult . data
37
41
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
40
47
41
48
const previewAnalyticsTag = {
42
49
injectTo : 'head' as const ,
@@ -126,7 +133,7 @@ export default defineConfig(({ mode }) => ({
126
133
} ,
127
134
} ) ,
128
135
react ( ) ,
129
- apiMode === 'dogfood ' && basicSsl ( ) ,
136
+ apiMode === 'remote ' && basicSsl ( ) ,
130
137
] ,
131
138
html : {
132
139
// don't include a placeholder nonce in production.
@@ -139,8 +146,7 @@ export default defineConfig(({ mode }) => ({
139
146
// these only get hit when MSW doesn't intercept the request
140
147
proxy : {
141
148
'/v1' : {
142
- target :
143
- apiMode === 'dogfood' ? `https://${ DOGFOOD_HOST } ` : 'http://localhost:12220' ,
149
+ target : apiMode === 'remote' ? `https://${ EXT_HOST } ` : 'http://localhost:12220' ,
144
150
changeOrigin : true ,
145
151
} ,
146
152
} ,
0 commit comments