fix(routing): redirect to home with warning for invalid network URLs#305
Merged
AugustoL merged 3 commits intoopenscan-explorer:devfrom Mar 12, 2026
Merged
Conversation
Invalid network segments like /undefined/txs silently fell back to Ethereum mainnet, showing misleading data. Now validates the network param against enabled networks and redirects to the home page with a warning notification when the network is not recognized. Closes openscan-explorer#290
|
🚀 Preview: https://pr-305--openscan.netlify.app |
… under navbar Warning notifications now have a yellow background tint and border. Notifications are positioned sticky under the navbar instead of fixed overlapping it, with rounded borders (12px).
…icate Notification container is now fixed at top 70px (under navbar), centered, max 520px wide. Warning style uses yellow tint. Added ref guard to prevent duplicate notifications from React Strict Mode.
josealoha666
approved these changes
Mar 12, 2026
Collaborator
josealoha666
left a comment
There was a problem hiding this comment.
Reviewed the routing diff and it looks good to me. Wrapping the dynamic :networkId routes in ValidateNetwork is a clean fix for #290, and using isNetworkEnabled(networkId) keeps invalid or disabled networks from silently falling back to mainnet. I also like that the warning is localized and only fires once before redirecting home.
Collaborator
josealoha666
left a comment
There was a problem hiding this comment.
Quick review: I skimmed the diff and did not find a clear blocker. Leaving a comment-only review for now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When navigating to an invalid network segment (e.g.,
/undefined/txs,/foo/blocks), the app silently fell back to Ethereum Mainnet and fetched incorrect data. Now it validates the network param and redirects to the home page with a warning notification.Related Issue
Closes #290
Type of Change
Changes Made
ValidateNetworklayout route component that checks the:networkIdparam against enabled networks/(home) and shows a warning notification: "The network X is not recognized...":networkIdroutes withValidateNetworkusing React Router's layout route pattern (<Outlet />)Screenshots (if applicable)
N/A — test by navigating to
/#/undefined/txsor/#/foo/blocksChecklist
npm run format:fixandnpm run lint:fixnpm run typecheckwith no errorsnpm run test:runAdditional Notes
The
ValidateNetworkcomponent usesisNetworkEnabled()from the networks config, which checks both that the network exists and that it's included in theREACT_APP_OPENSCAN_NETWORKSenv filter (if set). This means disabled networks will also redirect with a warning.