fridays / next-routes

Universal dynamic routes for Next.js
MIT License
2.47k stars 230 forks source link

Error: Route "..." already exists #74

Closed haywoood closed 7 years ago

haywoood commented 7 years ago

This technique had been working, installed the latest npm version and it's broken.

routes.add('entity', '/entity/:actor_id/:tab')
routes.add('entity', '/entity/:actor_id')

/node_modules/next-routes/dist/index.js:89 throw new Error('Route "' + name + '" already exists'); ^ Error: Route "entity" already exists

fridays commented 7 years ago

Sorry! A route name must be unique, but you can do this in one line:

routes.add('entity', '/entity/:actor_id/:tab?') // <- note "?"
haywoood commented 7 years ago

Oh nice, thank you, missed that syntax.