Hi @lmateo
Welcome to the Auth0 Community!
Reading through your use-case, I believe that the issue is likely related to the redirect_uri
parameter that needs to be set dynamically, based on the environment that you are running at any given time. You can read more on this from our documentation on how to Redirect Users.
The redirect_uri
sent in a /authorize request needs to point towards where you want your users to be redirected after a successful authentication - you can view the following Authorization URL example for the location of the request and it’s parameters.
To set the redirect_uri
dynamically, I suggest reading through our Knowledge Article on how to Configure Multiple Domains with NextJS .
Additionally, depending on the SDK that you’re using, redirect_uri: window.location.origin
is used to dynamically set the redirect so that, if you are running on localhost, window.location.origin should point to your localhost address.
Hope this helped!
Gerald