Files
mats 52ec290055
build / build-push (push) Successful in 29s
Fix console assets on nested routes
The relative Vite base made BrowserRouter pages request JavaScript and CSS under /auth/assets. The SPA fallback returned index.html for those paths, so the browser never mounted React and the sign-in page appeared blank. Emit root-relative asset URLs so every client-side route loads the embedded console bundle.
2026-09-27 22:51:04 +02:00

37 lines
1.3 KiB
TypeScript

import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
import { defineConfig } from 'vite'
// The Go binary serves the built assets and the API from the same origin, so
// the app always talks to a relative `/api` base. During development Vite
// proxies that prefix to a locally running fancy-dns.
export default defineConfig({
// BrowserRouter routes such as /auth/login are served by the SPA fallback.
// A relative base makes their asset URLs resolve under /auth/assets, which
// the fallback answers with index.html and leaves the page blank. Rooted
// URLs keep assets and API calls on the application origin at every route.
base: '/',
plugins: [react(), tailwindcss()],
server: {
proxy: {
'/api': {
target: 'http://127.0.0.1:8080',
changeOrigin: true,
// The logs SSE stream is long-lived: never time it out.
timeout: 0,
proxyTimeout: 0,
},
},
},
build: {
// The Go binary embeds the console via //go:embed all:dist in
// internal/web/web.go, so the build has to land there rather than in
// web/dist: a bundle nobody embeds is a console nobody can load.
outDir: '../internal/web/dist',
emptyOutDir: true,
sourcemap: false,
// Hashed asset names let the server cache them immutably.
assetsDir: 'assets',
},
})