Skip to content

docs(static-files): document before/after handler ordering#562

Draft
dawsontoth wants to merge 3 commits into
mainfrom
docs/static-ordering-options
Draft

docs(static-files): document before/after handler ordering#562
dawsontoth wants to merge 3 commits into
mainfrom
docs/static-ordering-options

Conversation

@dawsontoth

Copy link
Copy Markdown
Contributor

Draft until HarperFast/harper#1574 merges and its release version is confirmed — the v5.2.0 badges and changelog line in this page assume the next feature release; adjust if it ships under a different version.

What

Documents the static plugin's before / after handler-ordering options added in HarperFast/harper#1574, and fixes the SPA client-side routing example, which currently documents a config that breaks REST.

Why

The static handler runs before authentication — and therefore before the REST handler — by default. The existing "SPA client-side routing" example (notFound + fallthrough: false) therefore answers every unmatched GET with index.html, including GETs for exported REST resources: the application's API silently becomes unreachable over GET. This bit the create-harper SPA templates, fixed in HarperFast/create-harper#109.

With harper#1574 in place, one line makes the recipe work as readers assume it does:

rest: true

static:
  files: 'dist/**'
  after: 'rest' # let REST match first; only unmatched URLs get the fallback
  notFound:
    file: 'dist/index.html'
    statusCode: 200
  fallthrough: false

Changes to reference/static-files/overview.md

  • New Handler Ordering section: default position in the middleware chain, why it exists (file requests skip credential parsing), the fallthrough: false trap, the after: 'rest' recipe with request mappings, and the new startup warning.
  • before and after added to Additional Options (with v5.2.0 badges), including before: false to clear the default constraint.
  • SPA client-side routing example corrected to include after: 'rest', with a note about pre-5.2 behavior and a pointer to hash-based routing as the version-independent alternative (also keeps index.html cacheable at a single URL).
  • Custom 404 page example notes when after: 'rest' is needed.

Verification

  • npm run format:check clean; npm run build succeeds (the one broken-anchor warning is pre-existing in release-notes/v5-lincoln/5.1, unrelated to this page).
  • The behavior described was verified end-to-end against a built harper#1574 dist: with after: 'rest', REST resources return JSON while unmatched deep links receive the index.html fallback.

Related: HarperFast/harper#1574 - HarperFast/create-harper#109

🤖 Generated with Claude Code

The static handler runs before authentication (and therefore before REST)
by default, so the documented SPA recipe - notFound + fallthrough: false -
answered GETs for exported REST resources with index.html, making the API
unreachable over GET.

Documents the new before/after ordering options (HarperFast/harper#1574):
a Handler Ordering section explaining the default position and the
after: 'rest' recipe, ordering notes on the notFound option and the
custom-404 example, a corrected SPA example, and a pointer to hash-based
routing as the version-independent alternative.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the static files documentation to cover the new before and after handler ordering options introduced in v5.2.0, including a new section on handler ordering and updated SPA client-side routing examples. The review feedback focuses on improving clarity and technical accuracy, such as replacing colloquial terms like 'answers' with more standard terminology, and resolving a potential inconsistency regarding whether configuration changes require a restart.

Comment thread reference/static-files/overview.md Outdated
Comment thread reference/static-files/overview.md Outdated
Comment thread reference/static-files/overview.md Outdated
Comment thread reference/static-files/overview.md Outdated
@github-actions github-actions Bot temporarily deployed to pr-562 July 2, 2026 15:56 Inactive
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-562

This preview will update automatically when you push new commits.

dawsontoth and others added 2 commits July 2, 2026 11:56
…tically

Matches HarperFast/harper#1574, which now requests a component restart
when before/after change at runtime.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- "answers" -> "responds to" for the fallthrough: false behavior.
- Note the handler-ordering exception in the Auto-Updates section so it
  no longer appears to conflict with the ordering docs.
- Clearer SPA example intro ("does not match an API route or a static
  file") and "allows REST resources to be matched first".

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-562

This preview will update automatically when you push new commits.

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