Skip to content

Cell - Serve Static Component ​

Serves the frontend build from the backend. The fullstack template depends on it; projects without a frontend do not need it.

bash
npm install @celljs/serve-static

It serves serveStatic.root (default ${paths.public}, the public/ directory of the build output) with Cell's own file sender: Content-Type, a weak ETag, Last-Modified, Cache-Control, 304 for fresh requests, 412 for failed If-Match / If-Unmodified-Since, single byte ranges (206 / 416), dotfiles ignored, and paths that leave the root refused. With spa: true (default) unknown paths get /index.html, so client-side routes work on reload. When there is no frontend directory, requests pass through.

serveStatic.options: maxAge (milliseconds, default one year), immutable (default true), htmlMaxAge (Cache-Control of HTML files and web app manifests, .webmanifest, default 0), headers (added to every file), index (default index.html, false for none), extensions (tried when a path has none), dotfiles (ignore default, allow, deny), redirect (301 from a directory to its path with /), acceptRanges, cacheControl, etag, lastModified (default true), fallthrough (default true).

With cell build --single, the files are embedded in the server bundle and served from memory with the same headers.