Skip to content
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

Different behaviour for urls with and without trailing slash #686

Closed
donni106 opened this issue Jul 2, 2020 · 6 comments
Closed

Different behaviour for urls with and without trailing slash #686

donni106 opened this issue Jul 2, 2020 · 6 comments

Comments

@donni106
Copy link
Contributor

donni106 commented Jul 2, 2020

What is the problem?

I found out, that I can acces the index page http://localhost:3000/projects but not the same page with a trailing slash http://localhost:3000/projects/, which results in a 404.
Similar with http://localhost:3000/projects/new everything is fine, but http://localhost:3000/projects/new/ results in an error.

Steps to Reproduce

  1. open http://localhost:3000/projects -> works fine
  2. open http://localhost:3000/projects/ -> not found
  3. open http://localhost:3000/projects/new -> works fine
  4. open http://localhost:3000/projects/new/ -> error

Anmerkung 2020-07-02 231341

Versions

output of `blitz --version --verbose`

Linux 4.4 | linux-x64 | Node: v14.3.0

blitz: 0.16.0 (global)
blitz: 0.16.0 (local)

Other

There are inconsistancies across routes regarding trailing slashes. Some routes work with both versions, others not.
How should urls behave with and without trailing slashes in general?
Here is a blog post about the topic for further read: https://searchfacts.com/url-trailing-slash/
Found something next.js related here: https://stackoverflow.com/questions/57005120/how-can-you-handle-trailing-slashes-in-next-js-routes
In nextjs docs: https://nextjs.org/docs/api-reference/next.config.js/exportPathMap#adding-a-trailing-slash
Issue in nextjs repo: vercel/next.js#5214

@flybayer
Copy link
Member

flybayer commented Jul 4, 2020

Thanks @donni106! I'm assuming this works fine with plain Next.js. And judging by the Prisma error, it looks like maybe there is a bug with our useParam() hook?

Someone just needs to dig into this a bit and find the root cause :)

@donni106
Copy link
Contributor Author

donni106 commented Jul 4, 2020

This is possible for the error with e.g. .../projects/new/.

But for the 404 on .../projects/ I think it is something different. Have you checked the referenced issue in the nextjs repo? It is a long lasting discussion. There seems to be some difficulties also in plain nextjs.

@flybayer
Copy link
Member

flybayer commented Jul 4, 2020

Ok yeah I haven't dug into it. I'm currently focused on authentication, so hopefully someone else can look into this :)

@merelinguist
Copy link
Contributor

Yeah I think this is a Next problem, not a Blitz problem. In this Next Sandbox, users resolves, as does users/1, but users/ returns a 404.

@merelinguist
Copy link
Contributor

Update: looks like it’s being fixed! vercel/next.js#5214 (comment)

@merelinguist
Copy link
Contributor

This has now been fixed in Next, so I’m closing this. If you see the Sandbox I linked above, I’ve updated Next to the latest version, and the routes now seem to work correctly. Please feel free to open again if this problem persists!

@dillondotzip dillondotzip transferred this issue from blitz-js/blitz Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants