Skip to content
sproutboat
Esc
navigateopen⌘Jpreview
On this page

Static assets

Serve files from the edge, with your handler owning only the paths it wants.

Configuration

"assets": {
  "directory": "public",
  "binding": "ASSETS",
  "not_found_handling": "single-page-application",
  "run_sprout_first": ["/api/*"]
}

How requests are routed

The edge serves matching files directly. Your handler only calls env.ASSETS.fetch(request) for paths it wants to own (an SPA shell, an auth gate). This call returns text assets only — the edge handles binary files.

fetch(request) {
  const url = new URL(request.url);
  if (url.pathname.startsWith("/api/")) return handleApi(request);
  return env.ASSETS.fetch(request);
}

Options

Field Values Behavior
not_found_handling "none" A plain 404 from the edge.
"single-page-application" Unknown GETs serve index.html with a 200.
"404-page" Unknown paths serve /404.html with a real 404.
run_sprout_first true Every request goes to the handler first.
string[] (globs) Only matching paths go to the handler first — usually what you want, e.g. ["/api/*"].

Was this page helpful?