404 page not working for nested routes
See original GitHub issueDescribe the bug
I have a Next.js app with a custom pages/404.tsx
file. When accessing a route on the root of the domain that I expect to return a 404, this page renders fine (a.k.a domain.com/broken-url
). However, when trying to access nested routes under this that should return the 404 page, the default Next.js 404 template is shown instead (a.k.a domain.com/broken/this
)
Expected behavior
When testing this using npm run build
and npm run start
the expected behaviour of rendering the custom 404 page works.
Steps to reproduce
- Create custom
/pages/404.tsx
- Deploy using this component.
- Access
domain.com/broken-url
you will see the custom 404 page - Access
domain.com/broken/thisl
you will NOT see the custom 404 page
Versions
- OS/Environment: Mac OS Big Sur
- @sls-next/serverless-component version: 1.18.0
- Next.js version: 10.0.9
Checklist
- You have reviewed the README and FAQs, which answers several common questions.
- Please first try using the most recent
latest
oralpha
@sls-next/serverless-component
release version, which may have already fixed your issue or implemented the feature you are trying to use. Note that the oldserverless-next.js
component and theserverless-next.js
plugin are deprecated and no longer maintained.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Handle 404 pages for nested routes in react-router
Nested routes are common in react ecosystem, but the handling of not found pages is not great with them. Let's understand one of...
Read more >How to add a 404 page in react with nested routing?
You can use what you have, but change the route to path="*". This will make it so anything that is not a defined...
Read more >Routing - Remix
Nested Routing is the general idea of coupling segments of the URL to component hierarchy in the UI. We've found that in almost...
Read more >React Router v6: Handling 404 Pages & Passing Props to Link
So what if we want to render a 404 component if there is no matching route? In general, the webs that we visit...
Read more >React Router in Depth #5 - Custom 404 Page - YouTube
Watch the whole course now (without ads) on Net Ninja Pro: https://netninja.dev/p/react-router-in-depth Access the course files on ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m facing the same issue. I have a custom 404 page, and I’m not redirected to this page. I’m using @sls-next/serverless-component: 1.19.0-alpha.43 next: 10.1.2
Sounds good, then I think we can close this issue if the latest issues are with Next.js itself