Yes - I use it to redirect for email login back to...
# gotrue
f
Yes - I use it to redirect for email login back to the page user came from. For example - user accesses http : // mysite/example/ Using next js router I put { redirectTo:
${window.location.origin}${router.pathname}
, } and after login user will be redirected to that page. Of course the page has to be listed in redirect url section in supabase authentication setting in admin (you need to list each fully qualified url you might redirect to unfortunately ) and if your url ends with / in redirect section, redirectTo has to fully match. Hope that helps, but basically you can use it to make sure user is redirected after login to wherever you want. Key thing is urls matching to whats in supabase admin. Actually - maybe I'm mistaken as it's been a while. I think I use redirectTo when signing in with magic link to control where user is redirected after they click magic link. Everything else is the same.
c
Thanks, @User. There are a few things that I don't really understand: - it seems that this requirement to EXACTLY match the redirectTo URL to something that you specify in the admin console is either NOT entirely true OR it does NOT apply to sign-up email confirmation links. That is, I redirect from those links to URLs that share ONLY domain of what I have in the dashboard and it works fine. So I am not sure if the exact URL needs to match ONLY if the domain of the redirect URL does NOT match the base domain of the app. Do you know? - If you use redirectTo via a magic link, then that makes sense but it's a very different scenario from calling the signIn method from a SPA. The difference is that the magic link can easily return a 302 redirect response which the browser can follow, while the AJAX signIn call does NOT return 302 and even if it did - I don't think browsers follow redirects from AJAX calls