Skip to content

Explain how a root handler owns 404s for Functions - #59

Open
jordesign wants to merge 2 commits into
mainfrom
docs/functions-handler-404
Open

jordesign wants to merge 2 commits into
mainfrom
docs/functions-handler-404

Conversation

@jordesign

@jordesign jordesign commented Sep 30, 2026 •

Copy link
Copy Markdown

The Functions page says a root handler.ts claims "the whole site" but doesn't say what that does to 404s. Because the handler gets every path that isn't a file and its response is final, a 404.html in the tree is never served. The sf init scaffold's plain-text Not found fallback is then what visitors see on a mistyped URL.

Changes to content/(dynamic)/functions.mdx:

  • New "Static files first, then the worker" subsection: files are served before the worker, a root handler owns every miss, and how to get a 404 page (HTML from the handler fallback, or a functions/ router, where unclaimed paths get the nearest 404.html and then the Spacefast page).
  • A note under the sf init example that its fallback answers page URLs with plain text too, linking to the new subsection.

Checked against the runtime serving order: static first, then route-table dispatch whose response is terminal, then nearest 404.html, then the platform 404.

verify:prose, verify:public-safety and check pass locally.

View in Indent View in Slack
Tag @indent to continue the conversation here.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@indent

indent Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor
PR Summary

Explains on the Functions page what a root handler.ts does to 404s. It receives every path that isn't a file and its response is final, so a 404.html in the tree is never served for those paths.

  • New "Static files first, then the worker" subsection: files win over the worker, a root handler owns every miss, and two ways to get a 404 page. One is to return HTML from the handler's fallback. The other is a functions/ router, where unclaimed paths fall through to static handling: the SPA fallback, then the nearest 404.html, then the Spacefast page, with a link to the routing docs.
  • The file-router section now says unclaimed paths fall through to static handling instead of "a plain 404".
  • A note under the sf init --runtime functions example: its plain-text Not found fallback also answers mistyped page URLs.

Issues

All clear! No issues remaining. 🎉

1 issue already resolved
  • The new Functions text says an unclaimed path under a functions/ router gets the nearest 404.html and then the Spacefast page. The runtime serves a configured 200 SPA fallback shell before either of those. The unchanged file-router line also still calls this case "a plain 404". (fixed by commit 580c8f0)

CI Checks

All required CI checks passed on 580c8f0.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: c862125e-aa93-4e82-8b91-db254ed0d745


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread content/(dynamic)/functions.mdx Resolved

This branch was successfully deployed

1 active deployment
preview/docs/functions-handler-404 — 580c8f08 Deployed Sep 30, 2026 by spacefast[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant