Static Frontend Guide
Use frontend when you want EdgeBase to serve a prebuilt static app from the same origin as your API and admin UI.
What frontend Controls
import { defineConfig } from '@edge-base/shared';
export default defineConfig({
frontend: {
directory: './web/dist',
mountPath: '/',
spaFallback: true,
},
});
| Field | Meaning |
|---|---|
directory | Required build output directory to serve |
mountPath | Optional URL prefix for the bundle, default / |
spaFallback | Optional SPA navigation fallback to index.html for HTML requests |
Build Responsibility
EdgeBase does not run your frontend build command for you.
Build the bundle first, then run the command you want:
pnpm --filter web build
npx edgebase dev
Or:
pnpm --filter web build
npx edgebase deploy
Or:
pnpm --filter web build
npx edgebase pack --format portable
The same built output can be used with dev, deploy, docker build, and pack.
Request Routing
When frontend is configured, route precedence stays fixed:
/api/*stays reserved for the EdgeBase API/adminand/admin/*stay reserved for the admin dashboard/openapi.jsonstays reserved for the generated OpenAPI document- the frontend bundle serves everything else from
mountPath
This means static frontend serving is layered on top of the EdgeBase runtime surface rather than replacing it.
SPA Fallback And Asset Requests
With spaFallback: true:
- HTML navigation requests without a file extension can fall back to
index.html - missing asset requests such as
/assets/app.jsstill return404
This keeps SPA navigation behavior and static asset behavior distinct.
PWA Notes
If your frontend bundle already includes a valid manifest.webmanifest and service worker, the same-origin setup also works for PWA installs and local testing.
That PWA behavior comes from the frontend bundle itself plus same-origin serving.
How Other Commands Relate
How these commands use the built bundle:
devstarts a local runtimedeploypublishes a cloud runtimedocker build/docker runbuild and run a containerized runtimepackcreates a portable local artifact
If frontend is configured, each of those commands can use the same prebuilt static bundle.