Skip to content

Commit 3dd0629

Browse files
committed
add npm run start:colo
1 parent f591c28 commit 3dd0629

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"start": "API_MODE=msw vite",
1111
"start:msw": "API_MODE=msw vite",
1212
"start:nexus": "API_MODE=nexus vite",
13-
"start:dogfood": "API_MODE=dogfood vite",
13+
"start:dogfood": "API_MODE=remote EXT_HOST=oxide.sys.rack2.eng.oxide.computer vite",
14+
"start:colo": "API_MODE=remote EXT_HOST=oxide.sys.r3.oxide-preview.com vite",
1415
"preview": "API_MODE=msw npm run build && cp mockServiceWorker.js dist/ && vite preview",
1516
"dev": "API_MODE=msw vite",
1617
"start:mock-api": "tsx ./tools/start_mock_api.ts",

vite.config.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ import vercelConfig from './vercel.json'
1818

1919
const 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

2328
const apiModeResult = ApiMode.default('nexus').safeParse(process.env.API_MODE)
2429
if (!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
*/
3640
const 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

4148
const 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

Comments
 (0)