is there a way to embed a redirectToPath url argum...
# support-questions-legacy
a
is there a way to embed a redirectToPath url argument during the email verification process?
r
hey! The email verification process should redirect the user back to where they had navigated to. The redirect info is stored in localstorage. That being said, it will only work if the user opens the email verification link in the browser in which they had initiated the flow.
a
will this work even if multiple URLs are using the same supertokens authentication service?
for example "selfguard.xyz" and "demo.selfguard.xyz"
r
hmm. Well, you can make it work. Can you explain the user flow in more detail? Like an example of which domain they came from and in which do they do the email verification process.
a
so for example a user could originally signup at https://selfguard.xyz or they could signup at https://demo-file-storage.selfguard.xyz/. Either way, they should be able to login with the same account on each one. This all currently works, except that the email verification always defaults to https://selfguard.xyz/.
r
ah right. So, you can change that by dynamically changing the email verification URL to be either of the two domains by overriding the sendEmail function and reading the domain from the request object (present inside the userContext input to the sendEmail function)
a
awesome, do you have a snippet of how to extract the url from the user context?
r
The shape of the userContext variable will be:
Copy code
{
    _default: {
        /* 
        This is the request object that allows you to read the body / origin / headers of the API request.

        It is optional and will be defined only if the function you are overriding is called during an API.
        */
        request
    }
}
So you can do
userContext._default.request
and the type of request is the BaseRequest class: https://github.com/supertokens/supertokens-node/blob/9dc46cec9d/lib/ts/framework/request.ts So you can read headers using the
getHeaderValue
function. I think the origin of the request should be in the
"origin"
header name, but i don't remember of the top of my head.
btw, the site looks really cool πŸ™‚
one quick issue I found is that the password manager icon shows up somewhere else. and not in the password box. So you might wanna see how you have modified the default UI (if you are using our pre built UI that is)
a
awesome, really appreciate it!
and oh great catch!
also oddly enough getHeaderValue returns undefined
input.userContext._default.request.getHeaderValue()
r
You need to give it an argument
a
ahhh
r
Which is the name of the header
From the request object
a
i'm an idiot
that worked
'origin' as the argument
sorry about that haha
r
Hehe. Don’t worry about it. Happens to the best of us πŸ™‚
Happy that it worked
a
nice this worked like a charm!
r
Awesome!!
a
really appreciate the help
8 Views