https://supabase.com/ logo
Hello! Somebody is having troubles with the *redir...
# javascript
a
Hello! Somebody is having troubles with the redirect when you're pressing Forget my password ? In my LocalHost works fine, but as soon as I go to enviromment with Vercel always the URL which is arriving is just
${APP_HOST}
, is not arriving the rest /authentication/recovery-password , obviously I have the URL added to: Additional redirect URLs also in:
Copy code
js
  const resetPasswordForEmail = async (email) => {
    return supabase.auth.api.resetPasswordForEmail(email, {
      redirectTo: `${APP_HOST}/authentication/recovery-password`
    });
  };
Then I decided tu do the trick putting this /authentication/recovery-password
Copy code
js
<h2>Reset Password</h2>

<p>Follow this link to reset the password for your user:</p>
<p><a href="{{ .ConfirmationURL }}authentication/recovery-password">Reset Password</a></p>
Then looks like the URL arrives correctly but once I click It doesn't redirect to
authentication/recovery-password
but to
${APP_HOST}
Any solution please?
j
Hey this sounds like an issue with your app configuration possibly? Can you tell us more about your app stack?
a
Hello sure
What do you need to know?
I saw other users also having this problem
Now worked without I change anything
With this forced redirect
j
Is that redirect url part of your callback list in the supabase dashboard
a
It is
And now the second time I press again recovery password, sent to me the email , I click and I get redirect to / as was happening before
Copy code
js
  const resetPasswordForEmail = async (email) => {
    return supabase.auth.api.resetPasswordForEmail(email, {
      redirectTo: `${APP_HOST}/authentication/recovery-password`
    });
  };
Copy code
js
 const restorePassword = async () => {
    try {
      setLoading(true);
      const { error } = await resetPasswordForEmail(email);

      if (error) throw error;
      toast({
        title: t('pages.authentication.login.recoveryPasswordMail'),
        status: 'info',
        duration: 5000,
        isClosable: true
      });
      setForgotPassActive(false);
    } catch (error) {
      console.error(error.error_description || error.message);
      toast({
        title: error.error_description || error.message,
        status: 'error',
        duration: 5000,
        isClosable: true
      });
    } finally {
      setLoading(false);
      setEmail('');
    }
  };
@jaitaiwan might is because I'm not awaiting the supabase.auth?
j
Just looking through
@AdrianMsM91 {KBL}where are you setting up your routing? Cause the onAuthChange handler thing is where you are probably having issues
a
${APP_HOST}
you mean?
j
Nah
This is our "ProtectedRoute" component based off of react-router v5
a
But I don't get what you mean by routing in this case
j
Well when you click on the link from the email it redirects to supabase and then redirects to your app. So how does your app know to redirect correctly?