Hey, i have a auth web set up with react and i wan...
# support-questions
d
Hey, i have a auth web set up with react and i want to redirect upon successful sign in to a different url (my app) The auth web and the app web are in the same subdomain so i have like for example https://auth.my.subdomain.com and https://app.my.subdomain.com I tried using getRedirectionURL
Copy code
getRedirectionURL: async (context) => {
                if (context.action === "SUCCESS") {
                    let redirectUrl = context.redirectToPath

                    if (redirectUrl !== undefined) {
                        console.log("yoo redirected path");
                        console.log(redirectUrl)
                        // we are navigating back to where the user was before they authenticated
                        return redirectUrl
                    }
                }
                return undefined;
            },
I call the sign in with redirectToPath in the url like so https://auth.my.subdomain.com/auth?redirectToPath=https://www.app.my.subdomain.com and i get that the context.redirectToPath is empty and it just redirects me to the home page of my auth web instead to my web app. When i tried setting the web app url hardcoded in the return of getRedirectionURL it works like a charm and redirected me to the web app. Any idea if this is possible? or only paths are allowed to be redirected to? (Thanks for the help so far you have given me)
r
hey @Diesel
At the moment, we support redirection only to the same domain's path. To hack around this, you can redirect to some temp path on the same sub domain and make that redirect the user to the right sub domain
d
so like have https://auth.my.subdomain.com/webapp that redirects to https://app.my.subdomain.com ? just want to make sure
r
yea. You can make it redirect to
https://auth.my.subdomain.com/temp
or something like that, and that page's only purpose is to redrect to the other sub domain
d
great thanks ill give it a try
so i got confused with domain and subdomain. both of my web apps, the supertokens sign in web app and my actual web app, are in the same domain
.eatwoodspoon.com
but they live in different subdomains. So i cant redirect to the same domain only to the same subdomain?
r
yeaa.. you can't redirect them to a different sub domain via the
getRedirectionURL
function.
But as explained before, you can redirect them to a page on the same domain whose purpose is to redirect them to the application's domain
23 Views