fridays / next-routes

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

Redirects? #210

Closed shaqq closed 5 years ago

shaqq commented 6 years ago

Say I want routes like so:

/posts/:id -> go to /pages/post
/posts -> go to /

Is there a way to do that in the routes.js? Or do I have to add redirects into my server.js?

shaqq commented 6 years ago

Bump

nishtacular commented 6 years ago

@shaqq I reckon server redirects are your best option. Nice blog post here https://www.raygesualdo.com/posts/301-redirects-with-nextjs/

leotm commented 5 years ago

Yeah, I've just added

  .get('/a', (_req, res) => {
    return res.redirect('/b')
  })

which works for me.

shaqq commented 5 years ago

Cool, I guess server redirects are the way to go. My preference would be to have it all in one place, but I guess that's not easily done.