I created a account
folder in the pages
folder. And in this account
folder, I added a index.js
file.
I would like to reach this page through /account/
, but I get a 404 error. It is only reachable through /account
.
When I create a folder, I would like to be able to reach it with a trailing slash.
I think this is a duplicate of https://github.com/zeit/next.js/issues/5214. Out of curiosity, what is the reason that you MUST link with a trailing slash?
I have not written that I "MUST". I wrote that "I would like to". Please don't change my wording.
Sorry, that's not how I meant it. What I meant is: you could just only link to that page without a trailing slash. Unless something inside your project requirements makes this impossible. If it's impossible I'm interested in what dictates this requirement.
I'm only asking out of interest, not trying to put certain words in your mouth. Apologies if it seemed that way, the caps were only meant as emphasis.
Okay, I see what you mean. No problem!
Yes, I could link to that page without a trailing slash, and I currently do. But the URL would be more meaning full if I could add a trailing slash.
For the user, /account
means the account page, but /account/
means the account section of the website, i.e. that they are likely other pages in this section.
Our proxy appends trailing slash to any routes without it.
I agree with @lcswillems: users can enter the URL with the trailing slash, which results in a 404.
I feel it very hacky to remove the slashes manually, could next
offer any workarounds?
Just to add – some users regularly remove a part of the URL when navigating e.g. documentation, and some percentage of them leave the trailing slash, e.g.:
/section/subsection/page
/section/
I think a better default would be for Next.js to always automatically redirect to either with or without the trailing slash.
Update, I posted my workaround here: https://github.com/zeit/next.js/issues/5214#issuecomment-540713272
@Janpot the reason that I must use a trailing slash is because Social Login / OAuth federation providers require a trailing slash in their redirect URLs. One of the final pieces of functionality that I'm adding to the site is federated login and to find that ~ this ~ arbitrary decision is going to prevent that functionality is frustrating. Is there a technical reason for this decision that we could contribute to fixing or is this a stubborn design decision?
Maybe will it be solved with the new RFC on custom routing? (https://github.com/zeit/next.js/issues/9081)
Duplicate of #619
Most helpful comment
Just to add – some users regularly remove a part of the URL when navigating e.g. documentation, and some percentage of them leave the trailing slash, e.g.:
/section/subsection/page
/section/
I think a better default would be for Next.js to always automatically redirect to either with or without the trailing slash.