Expo redirect for reset password flow

I consider myself decently good at setting this kind of stuff up. But I can't figure this out. I'm unable to get the redirect to work correctly in the reset password flow. The redirect is always http://localhost:3000 in the email. I have set up every combination of redirect i can think of - attached inthe image. The redirect is created using makeRedirectUri from expo-auth-session though I have also tried Linking.createURL from expo-linking and they create the same url. Are there any other steps I'm missing?
No description
10 Replies
j4
j42mo ago
Can you show the code for your supabase login function?
kamcknig
kamcknigOP2mo ago
Method that invokes the reset method
const handlePasswordReset = useCallback(async () => {
setLoginErrorMsg('');
const msg = !email ? 'Enter your email to reset password.' : '';

if (!!msg) {
Toast.show(
msg,
{duration: 5000, position: Toast.positions.CENTER}
);

return;
}

// const redirectTo = makeRedirectUri();


const redirectTo = makeRedirectUri({
path: '/auth/reset'
});

const reset = await supabase.auth.resetPasswordForEmail(email, { redirectTo });

if (reset.error) {
Toast.show(
reset.error.message,
{duration: 5000, position: Toast.positions.CENTER}
);
} else {
Toast.show(
'Password reset email sent. Check your inbox.',
{duration: 5000, position: Toast.positions.CENTER}
);
}
}, [email]);
const handlePasswordReset = useCallback(async () => {
setLoginErrorMsg('');
const msg = !email ? 'Enter your email to reset password.' : '';

if (!!msg) {
Toast.show(
msg,
{duration: 5000, position: Toast.positions.CENTER}
);

return;
}

// const redirectTo = makeRedirectUri();


const redirectTo = makeRedirectUri({
path: '/auth/reset'
});

const reset = await supabase.auth.resetPasswordForEmail(email, { redirectTo });

if (reset.error) {
Toast.show(
reset.error.message,
{duration: 5000, position: Toast.positions.CENTER}
);
} else {
Toast.show(
'Password reset email sent. Check your inbox.',
{duration: 5000, position: Toast.positions.CENTER}
);
}
}, [email]);
j4
j42mo ago
Might be an issue in your reset email template. How is the url being constructed there?
kamcknig
kamcknigOP2mo ago
it's still the default template
<h2>Reset Password</h2>

<p>Follow this link to reset the password for your user:</p>
<p><a href="{{ .ConfirmationURL }}">New Reset password</a></p>
<h2>Reset Password</h2>

<p>Follow this link to reset the password for your user:</p>
<p><a href="{{ .ConfirmationURL }}">New Reset password</a></p>
I saw in the documentation if using the redirect, it might have to be changed but I tried that too. Even when I use the {{ .RedirectTo }} template variable, that itself just evaluates to http://localhost:3000
j4
j42mo ago
I'm sure the expo redirect is different than most, but it's the equivalent of an FQDN, right? It can't be relative.
kamcknig
kamcknigOP4w ago
the redirect I send to supabase from the app is exp://192.168.xx.xx Yes, it's equivalent AFAIK It works when I use someting like https://google.com So is no one even able to tell me that this simply isn't supported? I can't get info about this on the discord, via google, stackoverlfow, or even supabase's documentation.
j4
j44w ago
I know we have expo users, so I suspect it is supported; there just aren't many hanging around to help others.
kamcknig
kamcknigOP4w ago
Well for full info for anyone else as well; I was also able to get it to work with a custom scheme in a development build. So far only the exp:// scheme will not work
garyaustin
garyaustin4w ago
No idea if this is any help: https://blog.theodo.com/2023/03/supabase-reset-password-rn/ I also saw lots of web hits on supabase expo password reset but no idea if they are current or apply to you as I don't use expo either.
kamcknig
kamcknigOP4w ago
that's a good article, but unfortunately not. I have it all working with normal web URLs and a development build, just no expo go build :/ I've seen vague references saying it might not be supported, but can't find any official word anywhere

Did you find this page helpful?