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

params mismatch between client/server #10

Closed
scf4 opened this issue Mar 8, 2017 · 1 comment
Closed

params mismatch between client/server #10

scf4 opened this issue Mar 8, 2017 · 1 comment

Comments

@scf4
Copy link

scf4 commented Mar 8, 2017

I have the route /post/:slug-:id. It works fine on the client, but when SSRing I get a 500 error if the slug has a hyphen in it. I think it interprets the :id as the first thing after the first hyphen.

@fridays
Copy link
Owner

fridays commented Mar 8, 2017

Hey that's right, the regex stops at the first hyphen and assigns the rest to id. You can define the route like this to avoid it:

/post/:slug-:id([^-]+)

It uses path-to-regexp to match the routes, check it out for more examples. The reason that it works on the client is that the URL is only a decoration there and is not used for matching params.

@fridays fridays closed this as completed Mar 8, 2017
SeanDemps pushed a commit to SeanDemps/next-routes that referenced this issue Dec 13, 2018
Update dependency @types/next to v7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants