Basic Configuration
Minimal Setup
The simplest configuration:- Auto-detects mode based on
MIZU_ENV - Serves from
./distin production - Proxies to
http://localhost:5173in development - Ignores
/api,/health,/metrics
With Dev Server
Specify both production and development:Embedded Filesystem
Use embedded files for single-binary deployment:Options Reference
Mode
Controls how the middleware operates.MIZU_ENVGO_ENVENV
"production" or "prod" (case-insensitive) → Production mode
Otherwise → Development mode
Root
Directory containing built frontend files (production only).- Relative paths are relative to working directory
- Absolute paths work as expected
- Vite:
"./dist" - Angular:
"./dist/my-app/browser" - Next.js:
"./out" - Nuxt:
"./dist"
FS (Embedded Filesystem)
Embedded filesystem for production builds (takes precedence overRoot).
fs.Sub?
The embed directive includes the directory name:
fs.Sub extracts the subdirectory:
index.html is at the root level as expected.
Index
The fallback HTML file for SPA routing.- Request path is
/or empty - Requested file doesn’t exist (SPA fallback)
- Requested path is a directory
DevServer
URL of the frontend development server.- Vite:
"http://localhost:5173" - Angular:
"http://localhost:4200" - Next.js:
"http://localhost:3000" - Create React App:
"http://localhost:3000"
DevServerTimeout
Timeout for requests to the dev server.ProxyWebSocket
Enable WebSocket proxying for HMR.Prefix
URL prefix for serving the frontend./app→index.html/app/about→index.html(SPA fallback)/app/assets/main.js→assets/main.js/→ Not handled by frontend middleware
IgnorePaths
Paths that bypass the frontend middleware and go to Go handlers.CacheControl
Configure caching behavior for different asset types.- HashedAssets: Files with content hash in name (e.g.,
main.abc123.js) - UnhashedAssets: Files without hash (e.g.,
logo.png) - HTML: HTML files (
.html) - Patterns: Custom patterns override defaults
SecurityHeaders
Enable automatic security headers.SourceMaps
Allow serving source map files (.js.map, .css.map).
Manifest
Path to build manifest for asset mapping.- Asset fingerprinting
- Module preloading
- CSS injection
- Template helpers
InjectEnv
Inject server-side environment variables into the frontend.window.__ENV__:
InjectMeta
Inject custom meta tags into HTML.ServiceWorker
Path to service worker file for PWA support.ErrorHandler
Custom error handler for frontend errors.NotFoundHandler
Custom handler called before SPA fallback.Configuration Examples
Complete Production Setup
Development-Optimized Setup
Auto-Switching Setup
Multi-Environment Setup
Environment Variables
Configure via environment:Next Steps
Development Mode
Learn about dev mode and HMR
Production Mode
Optimize for production deployment
Caching Strategy
Deep dive into caching
Security
Security best practices