Skip to content

fix: don't overwrite history with 404 page#583

Open
Aeledfyr wants to merge 1 commit intoNerimity:mainfrom
Aeledfyr:404-fix
Open

fix: don't overwrite history with 404 page#583
Aeledfyr wants to merge 1 commit intoNerimity:mainfrom
Aeledfyr:404-fix

Conversation

@Aeledfyr
Copy link
Contributor

@Aeledfyr Aeledfyr commented Feb 28, 2026

This makes unknown routes return the 404 page directly, rather than overwriting the current history entry with /404. This is partially for convenience when working with DEV-only pages (#576), but it's also better behavior overall -- the 404 handler shouldn't overwrite the url, since it makes figuring out why it failed harder.

Did you test your code?

Tested on Firefox on desktop and Chrome on android.

Checklist

  • Changes are clear, concise, and easy to review
  • Code has been tested and works as intended
  • Text/content changes support internationalization (i18n)
  • Any new user-facing strings are properly localized

Summary by CodeRabbit

  • Bug Fixes
    • Fixed route handling for unmatched URLs to provide a more direct and efficient error page display.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dfb5e84 and a3f76ae.

📒 Files selected for processing (1)
  • src/index.tsx

📝 Walkthrough

Walkthrough

The catch-all route handler was refactored to use the NotFound component directly instead of the AllOther helper function which previously redirected to /404 via location.href. The function is removed entirely, and unmatched routes now render the component directly rather than performing a page redirect.

Changes

Cohort / File(s) Summary
Routing Handler Refactor
src/index.tsx
Replaced AllOther helper function with direct NotFound component usage for catch-all route; changed behavior from location.href redirect to client-side component rendering.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰✨ A path once lost now finds its way,
No more redirects to lead astray,
NotFound renders clean and bright,
AllOther hops out of sight! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: replacing a redirect to /404 with direct rendering of the NotFound component, which prevents history overwriting.
Description check ✅ Passed The description covers the main objective and testing, but omits the 'What does this PR do?' section and lacks the 'Additional context' section from the template.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@SupertigerDev
Copy link
Member

SupertigerDev commented Feb 28, 2026

it was done like this because i wanted to html to load status code 404 using nginx

@Aeledfyr
Copy link
Contributor Author

Aeledfyr commented Feb 28, 2026

Would it be possible to use a proper redirect? The current approach seems to be replacing the history entry for the invalid url (or something else; the invalid url doesn't show up in the back history)

@SupertigerDev
Copy link
Member

not sure how i would do that hm

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