diff --git a/app/api/__tests__/safety.spec.ts b/app/api/__tests__/safety.spec.ts index c31f4621a2..2af4a0cff1 100644 --- a/app/api/__tests__/safety.spec.ts +++ b/app/api/__tests__/safety.spec.ts @@ -83,6 +83,18 @@ it('e2e tests are only in test/e2e or test/visual', () => { } }) +// In production, Nexus only serves /assets/* and /index.html — files at other +// paths under public/ would work in Vite dev but 404 in production. +// https://github.com/oxidecomputer/omicron/blob/b2b1e39/nexus/src/external_api/console_api.rs#L409-L439 +it('public/ only contains assets/', () => { + const entries = fs.readdirSync(path.resolve(__dirname, '../../../public')) + expect(entries).toMatchInlineSnapshot(` + [ + "assets", + ] + `) +}) + // 8-4-4-4-12 hex digits const UUID_RE = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}' diff --git a/public/theme-init.js b/public/assets/theme-init.js similarity index 100% rename from public/theme-init.js rename to public/assets/theme-init.js diff --git a/vite.config.ts b/vite.config.ts index 396c72f8b4..5d7923d290 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -133,21 +133,21 @@ export default defineConfig(({ mode }) => ({ }, { // Inject theme-init.js as a classic (non-module) render-blocking script - // so it sets data-theme before first paint. It lives in public/ so it - // passes CSP default-src 'self'. We inject it here rather than putting - // it in index.html because Vite tries to bundle any