Best way to handle dynamic routes? #11486
Unanswered
Gustavo-Feijo
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
With v5, which would be the best way to handle dynamic routes?
I'm developing a simple personal project, and i wanted to add authentication to a dynamic route, but i didn't found nothing about it into the docs.
When using the auth as a wrapper for the routes we lose the context from the routes.
For example, in the code below is not possible to access the context from a dynamic route inside the GET(req):
export const GET = auth(async function GET(req){})
Usually when using something like this would work just fine without the auth:
export async function GET(req,{ params})
My main question is about which would be the preferred way to get the params and implement the authentication.
The two ways that i tried and worked out where:
1 - Creating a normal endpoint with the params and just calling the auth() inside.
2 - Use the endpoint as a wrapper for passing down the session.
Are these two fine to use? There is any better option?
There is any way to access the params directly within the auth wrapper?
Thanks in advance for any enlightenment about this.
Beta Was this translation helpful? Give feedback.
All reactions