trailingSlash + custom 404 + next export defaults to default 404 page.
See original GitHub issueBug report
Describe the bug
When using a trailing slash (e.g. /about/) and a custom 404 page, the custom 404 page does not appear, rather the default 404 page is used instead.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Create and set
trailingSlash: true
in next.config.js - Create a
404.js
page in the/pages
folder(pages/404.js)
- Run
yarn next build
andyarn next export
- Run
yarn next dev
- Go to a page that does not exist and you see the defualt 404 page.
Reproduction Repo:
http://github.com/pateljoel/nextjs-issue-16528
Expected behavior
My own custom 404 page on every page that does not exist.
System information
- OS: macOS
- Browser Chrome
- Version of Next.js: 9.5.2
- Version of Node.js: v12.16.2
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:8 (2 by maintainers)
Top Results From Across the Web
404 page is not showing in nextjs after export - Stack Overflow
I've added a custom 404.js file in /pages directory and it's working fine locally but when I run next export and put all...
Read more >18 Making a custom 404 page in Next.js - YouTube
Chapter Eighteen : Making a custom 404 page in Next.js and 503 ... 404 page in Next.js | Redirect to 404 | trailingSlash...
Read more >Configuring a custom error document - Amazon Simple ...
Configure your Amazon S3 bucket as a website by providing a custom error ... For example, when an HTTP 404 Not Found error...
Read more >Making a custom 404 page in Next.js - Netlify
Why have a boring default error page when you can spruce it up? Next.js has a custom static 404 page built right into...
Read more >Client-Side Routing In Next.js - Smashing Magazine
Each page is a default exported React component from the pages directory that can be used to define the most common route patterns....
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 was able to hack a workaround by including a
/404
export in the path map and copying the file into theout
dir root in a post build step.I have this same problem. I am deploying to Digital Ocean’s new App service like Vercel’s Now, and I need to set
so that
/music
renders pages/music.js instead of having to navigate to/music.html
But setting that also alters my custom 404.js which does require 404.html
So fixing the routes breaks my custom 404 page, and vice-versa.
I tried to create folders for each page such as
/music
,/about
and insert index.js, but it still treats the files the same way as if they were music.js, about.js inside /pages.