trailingSlash + unexistent page should return 404 instead of 308 + 404
See original GitHub issueBug report
Describe the bug
When a route does not exist and does not have the trailingSlash, for example:
localhost:3000/whatever
First it’s redirecting with 308 to:
localhost:3000/whatever/
And then is displaying the 404 page with the status 404.
To Reproduce
- Add
trailingSlash: true
on the next.js config - Curl an unexisting URL without trailingSlash
Expected behavior
Would be better to directly display the 404 page avoiding the 308 redirecting for these cases.
Screenshots
System information
- OS: macOS
- Version of Next.js: 9.5.2
- Version of Node.js: 14.8.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
trailing slash results in 404 error page CSS not working
I have redesigned a website. I've set up a 404 error page so that visitors with bookmarks to now non-existent pages or pages...
Read more >Redirect /file/ to /file (strip trailing slash) - Caddy Community
Caddy should spit a 404 back at you if you try to navigate to a non-existent site. The handle_path directive is for Caddy...
Read more >Returning 404 instead of redirecting on misspelled page
The reason you should use a page for 404 request is: in WP 404 page actually is a page that doesn't exists, WP...
Read more >Monitoring and fixing 404 errors with Google Analytics
This article explains two very simple custom reports for Google Analytics that you can use to monitor and fix 404 errors on your...
Read more >404 errors on non-existent URLs | SEO Forum - Moz
Should 404's be added across all folders on a site in a similar way? ... I've worked on) is that you do want...
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 can confirm what @aralroca is saying, when you manage a large set of urls, and you want to improve the performance of googlebot indexing them, that’s an small improvement, because serving a 308 triggers a new crawl actoin, to finally fetch a 404. (It’s better, in terms of performance to just serve the 404).
I thought that for SEO as fewer redirects possible better, and showing the page 404 directly made sense in this case. I have reported it because we had implemented it with a custom server before this feature landed in the new version of Next. But it is likely that I am wrong, so if it is done so because it is considered better, ok 👍