NextJS auth0 library:
I am following the v4 migration guide and have almost everything working except one thing. I have a need to dynamically set the redirect_uri and was able to previously do so with the route handlers. Now, according to the guide, you can just supply authorization parameters as search params after login route ‘/api/login?whatever’ but this is not working.
I try to set redirect_uri dynamically here and it simply uses the APP_BASE_URL or localhost:3000 if there is no app base url. Is this a bug? How can we dynamically specify redirect uri?
Edit:
Overriding scope does work but redirect_uri does not
Hi @Sebastian.Salazar
Thank you for reaching out to us!
I believe you are definitely on the right track, the only immediate issue that I can see would be that the authorization parameters required for forwarding to the /authorize endpoint needs to be under this format : <a href="/auth/login?audience=urn:my-api">Login</a>
This is pulled from the migration guide and would replace the login route that you mentioned, under the format of ‘/api/login?’
Hope that helped!
Gerald
1 Like
I was putting it in the correct format and it still doesnt work. For a more specific example i did <a href="/auth/login?redirect_uri=http://localhost:8080>Login
But when i inspect the network request to the authorize endpoint, redirect_uri parameter is still http://localhost:3000
I looked inside the source code in github and noticed that it might not be supported to update MOST params, i included a screenshot of what im referring to.
If the screenshot is accurate, it means we are not longer able to dynamically set the redirect_uri, and we were able to do this in the previous version of the library through modifying the login/callback handlers
Hi @Sebastian.Salazar
Thank you for the additional details!
It seems like the V4 migration guide suggest to append the authorization parameters as opposed to using route handlers as you mentioned previously using and working. I was not able to find and confirm that the route handler are no longer an option or that the auth/login?audience
format is now the only way this will work.
Could you try using route handlers in V4 and see if those are still supported and work? We don’t seem to have any reported issues with regards to this issues, which would indicate that one way or another it still works, either by passing the authorization parameters ( new way in V4 ) or the " older " way.
Let us know if route handlers are still managing this on your end.
Best regards,
Gerald
I dont think a lack of reported issues indicates that it still works. This is admittedly an edge case and seeing as this is a new version of the library, its very well possible that it hasnt been encountered yet. Route handlers are no longer a thing and this can be easily verified by looking at the docs: @auth0/nextjs-auth0 - v4.4.2
And once again, authorization parameters do not work. It explicitly says in the source code which ones can and cannot be overridden. redirect_uri, the one i am trying to override, is clearly stated as a param that cannot be overriden. I appreciate your attempt to help but if you are not going to bother actually digging into this, i prefer to wait for help from someone who will.