Hi, I want to have this configuration in the routes file with next-routes:
module.exports = routes()
.add({ name: "perfil", pattern: "/perfil/:id", page: "perfil" })
.add({ name: "edit", pattern: "/perfil/:id/edit", page: "edit" })
One component called "edit" that has the route /perfil/:id/edit and other for "perfil" which is /perfil/:id.
But that does not work, the component "perfil" gives me the route /perfil/:id and the component "edit" gives me /edit. How can i resolve this?
Thanks!
same issue:
.add({name: 'category', pattern: '/:id', page: 'category'})
.add({name: 'post', pattern: '/:category/:slug+', page: 'blog'});
You should put the most specific first. Because here /product/123 matches /:id, where id is product/123.
Oh, same does not matter... I use now 2.0 and I don't use the server.js file
@AugustinLF got the same issue with this change.
Works fine, at least for the current needs. Maybe i have to implement somekind of URLResolver on the API side.
.add({name: 'category', pattern: '/:id+', page: 'content'})

@juliankoehn why not just create the typical way to create routes in nextjs? In the server.js you put those routes and it's like if you were implementing a rest API...
@MontoyaAndres like that? https://zeit.co/guides/custom-next-js-server-to-routes#step-3:-defining-routes-configuration
Thank's!
Well that's usefull if we would host at @Now if i'm not misunderstanding the docs
@juliankoehn the example you sent is using now, which is great, I use it. But what I was talking about is this https://github.com/zeit/next.js/blob/canary/packages/next/README.md#custom-server-and-routing
@MontoyaAndres it's nearly doing the same as i did within the getInitialProps, i'll keep it at mind and maybe swap over in point of performance.
Thanks for sharing :-) 馃憤
I'm going to close this issue because the author never responded.
Most helpful comment
You should put the most specific first. Because here
/product/123matches/:id, whereidisproduct/123.