fix: resolve 404 error on page reload for GitHub Pages SPA routing#120
fix: resolve 404 error on page reload for GitHub Pages SPA routing#120Gitjay11 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughAdded GitHub Pages SPA fallback handling: ChangesSPA route recovery
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Addressed Issues:
Fixes #112
Screenshots/Recordings:
Before — As shown in the issue, navigating to
orgexplorer.aossie.org/repositoriesand refreshing shows GitHub Pages' 404 error (see #112 for the recording).
After — The fix will be verified post-merge once deployed to GitHub Pages.
How it works:
When GitHub Pages can't find a file at a path like
/repositories, it serves our custom404.html, which encodes the path and redirects to/?/repositories. A decode script inindex.htmlthen restores the real URL viahistory.replaceState()before React mounts, so React Router renders the correct page seamlessly.Additional Notes:
public/404.html(new) — intercepts GitHub Pages 404s and encodes the path as a query string redirect.index.html(modified) — decodes the redirected path and restores the correct URL before React Router mounts.Checklist
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.
Summary by CodeRabbit