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.

Nextjs should have more options for trailing slash.

See original GitHub issue

Feature request

Is your feature request related to a problem? Please describe.

Nuxtjs have several options to choose trailing slash. (undefined, true, false) nuxt-community/nuxt-i18n#422

Describe the solution you’d like

Nextjs should have more options for trailing slash. If use undefined Nextjs should not redirect route when use URL that ends with a slash

trailingSlashes: true

/abc/ -> /abc/ (keeps the same) /abc -> /abc/ (changes)

trailingSlashes: false

/abc -> /abc (keeps the same) /abc/ -> /abc (changes)

trailingSlashes: undefined (default)

/abc/ -> /abc/ (keeps the same) /abc -> /abc (keeps the same)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:50
  • Comments:27 (12 by maintainers)

github_iconTop GitHub Comments

26reactions
Daemeroncommented, Sep 29, 2020

I think not being forced to opt-in into automatic trailingSlash url normalisation would be very helpful. My team wanted to upgrade to latest version of Next.js recently but this change keeps us from doing so.

Our use-case is international website that does not use trailing slashes at the end of the url except for home pages for different countries:

  • /gb-en/ <- home page /
  • /gb-en/page-1 <- page-1 /page-1

We would benefit from trailingSlashes: undefined (default)

9reactions
Zauberfischcommented, Jan 3, 2021

On second thought, keep it simple, let’s just add an option to disable redirects.

This way we have a quick implementation time and we can implement a more complex solution later. Also, there are other ways to implement redirects (custom app, webserver in front of next, …) (I personally do all redirecting with apache or nginx, so I don’t actually want apps to do those themselves)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nextjs should have more options for trailing slash. #23988
Nextjs should have more options for trailing slash. If use undefined Nextjs should not redirect route when use URL that ends with a...
Read more >
Trailing Slash - next.config.js
By default Next.js will redirect urls with trailing slashes to their counterpart without a trailing slash. For example /about/ will redirect to /about...
Read more >
How can you handle trailing slashes in next.js routes?
This will ensure that all routes that end with a trailing slash are redirected to the non-trailing slash path via a 301 redirect....
Read more >
How to Add Trailing Slash in NextJS Routes
In NextJS default configuration, the framework will remove the last slash in your route also called the trailing slash.
Read more >
Trailing Slash vs No Trailing Slash – Whats Better for SEO?
When it comes to trailing slashes, some are for them, and some are against them. A trailing slash is the slash on the...
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