Skip to content

fix(middleware): keep handler 404 responses with Static HTML5 mode#2984

Open
leno23 wants to merge 1 commit into
labstack:v4from
leno23:fix/static-html5-handler-404
Open

fix(middleware): keep handler 404 responses with Static HTML5 mode#2984
leno23 wants to merge 1 commit into
labstack:v4from
leno23:fix/static-html5-handler-404

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 25, 2026

Summary

  • Restrict Static middleware HTML5 SPA fallback to router-level 404 responses
  • Skip index.html fallback when a matched handler returns its own 404 (e.g. API resource not found)
  • Add regression test covering /api/test/3 JSON 404 vs /client-route SPA index fallback

Test plan

  • go test ./middleware/...
  • TestStaticHTML5DoesNotOverrideHandler404

Fixes #2775

Made with Cursor

HTML5 fallback to index.html should apply only to router-level 404s,
not to 404 errors returned by matched API handlers behind the static
middleware.

Fixes labstack#2775

Co-authored-by: Cursor <cursoragent@cursor.com>
@aldas
Copy link
Copy Markdown
Contributor

aldas commented May 25, 2026

Could you explain what use-case/issue this is solving?

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.

2 participants