-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to configure baseUrl
when using Vercel preview environment, to stay on the same domain?
#420
Comments
Hey @Vadorequest When instantiating the SDK you can either use the named exports (eg, export default handleAuth({ // Creates an instance of the SDK
async login(req, res) {
initAuth() // Creates another instance of the SDK You're getting You could lazily create an insance of the SDK on the first request, eg let instance;
export default (req, res) {
...
instance = instance || initAuth0({ baseURL: previewEnvBaseUrl });
return instance.handleAuth(...)(req, res);
}; But there is probably a better solution around figuring out the url at build or boot time - is there no way you can derive the preview url from |
I don't believe that's possible. That's because when using custom domain (eg: domain name based on the git branch), it redirects from something like This is an issue that's bound to happen with any website that has several domains attached to it, I need the user to stay on the same domain. |
I'm confused - what do you want the |
It would work but only solves half of the problem.
My goal is to stay on the same domain, not to hardcode the domain. Vercel
provides several domain aliases and it shouldn't switch from one domain to
another during navigation.
…On Fri, Jun 18, 2021, 18:14 Adam Mcgrath ***@***.***> wrote:
This is an issue that's bound to happen with any website that has several
domains attached to it, I need the user to stay on the same domain.
I'm confused - what do you want the baseUrl to be in your example?
git-fix-auth0.vercel.app? If so, could you not construct that from
${VERCEL_GIT_COMMIT_REF}.vercel.app?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#420 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA5BRYRRCUEYLCJANOV3DQLTTNWFVANCNFSM465ZTS2Q>
.
|
So, my above strategy was to detect the domain on the front-end and pass it
down to the backend API call, but I've been unsuccessful so far because
Auth0 doesn't easily allow to use a dynamic domain.
On Fri, Jun 18, 2021, 19:09 Ambroise Dhenain ***@***.***>
wrote:
… It would work but only solves half of the problem.
My goal is to stay on the same domain, not to hardcode the domain. Vercel
provides several domain aliases and it shouldn't switch from one domain to
another during navigation.
On Fri, Jun 18, 2021, 18:14 Adam Mcgrath ***@***.***> wrote:
> This is an issue that's bound to happen with any website that has several
> domains attached to it, I need the user to stay on the same domain.
>
> I'm confused - what do you want the baseUrl to be in your example?
> git-fix-auth0.vercel.app? If so, could you not construct that from
> ${VERCEL_GIT_COMMIT_REF}.vercel.app?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#420 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AA5BRYRRCUEYLCJANOV3DQLTTNWFVANCNFSM465ZTS2Q>
> .
>
|
This answer looks like what I was looking for. |
@Vadorequest - yep, if you don't know the URL until request time - then that would work Closing this - feel free to ping me if oyu'd like to discuss further |
Worth noting what's here on this example page. (You can skip modding the build command and output directory.) |
Description
In production and in preview environments, we configured Vercel
AUTH0_BASE_URL=VERCEL_URL
env var. It works fine in production, but on preview it changes the domain, becauseVERCEL_URL
doesn't use a custom domain name but the domain dynamically generated for the deployment.We're not using
initAuth0
in the app and we rely on theAUTH0_BASE_URL
, but I believe we need to make an exception in the preview environment by detecting the current domain and configure Auth0 to redirect to that same domain after being authenticated.I tried to adapt our
[...auth0].ts
file to handle that edge case, but it didn't seem to work as I getTypeError: "baseURL" is required
. (I've disabledAUTH0_BASE_URL
for the Vercel preview environment)Reproduction
HomeScreen.tsx
[...auth0.ts]
I assumed using
initAuth0
and providing abaseURL
value would work.I'm a bit confused by how
handleAuth
HOC works and I might not be doing things correctly. ThepreviewEnvBaseUrl
contains the expected value, so the issue lies in how to configure Auth0 to use the proper domain.Environment
The text was updated successfully, but these errors were encountered: