question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

trailingSlash + unexistent page should return 404 instead of 308 + 404

See original GitHub issue

Bug 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

  1. Add trailingSlash: true on the next.js config
  2. 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

image

System information

  • OS: macOS
  • Version of Next.js: 9.5.2
  • Version of Node.js: 14.8.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
jordiccommented, Aug 27, 2020

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).

1reaction
aralrocacommented, Aug 26, 2020

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 👍

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found