-
Notifications
You must be signed in to change notification settings - Fork 27.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client vs Server routing: different results based on path #619
Comments
I think it should work like node's |
In that case, this would fix the behavior (two lines added in if (i[i.length - 1] === sep) {
return [
i.slice(0,-1) + '.json', // removing the separator in case it's in the last pos
i + 'index.json',
i.slice(0,-1) + '.js', // removing the separator in case it's in the last pos
i + 'index.js'
]
} should I make a PR with this? |
@alexnm go for it. |
@alexnm Actually, it tries to mimic the behavior of
So I think we'd have to fix somewhere different. |
@nkzawa yes, but I think the browser behavior should be the same regardless of the url ending in And in this case the server should behave like the browser. |
@alexnm yeah but I'm still not so sure about that since next.js is filesystem based API (not express-like routing). If you need it, you can do it using programmatic API. |
@nkzawa should we close this? I tried thinking of different approaches, but I see none that has no downsides. |
I think it's still the problem since it should render a same page on client and server. putting it all together: For the url
For the url
This makes sense as filesystem based API and also is compatible with how |
Additionally, made the table the in alphabetic order 👌
The latest version(s) of Next.js warn in this case. Once of the pages need deleted. This will likely be an error sometime in the future (a major version):
|
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Here's an example folder structure (as silly as it may be)
If I have a
<Link/>
point to/subpage/
the client will render the component fromsubpage.js
, but when I refresh the page, I get thesubpage/index.js
file rendered.At first I noticed this was an issue with the server routing not working well if the path ends with a
/
, but then I realized that there are cases in which you may want anindex.js
in a folder, so it's not necessarily problematic that you get a404
when you don't have theindex.js
.However, when there's a naming collision between a file and a folder, the client and the server behave differently and I think there should be a discussion around this situation, because I can't say there's a clear solution at this point.
The text was updated successfully, but these errors were encountered: