wittgenstein
wittgenstein

Reputation: 4482

How to handle redirect from supabase password recovery?

I can't figure out how I can create a custom supabase url to recover the password:

current url in the mail:

https://url.supabase.co/auth/v1/verify?token=XYZ&type=recovery&redirect_to=https://example.vercel.app/

expected url:

https://url.supabase.co/auth/v1/verify?token=XYZ&type=recovery&redirect_to=https://example.vercel.app/recover


approaches:

  1. Use supabase config

Could not read verification params: json: cannot unmarshal object into Go struct field RecoverParams.email of type string

  1. use onAuthStateChange
  1. use a middleware

What would you suggest?

I am using Nuxt 3, Vercel and Supabase

Upvotes: 0

Views: 3338

Answers (1)

Joel Lee
Joel Lee

Reputation: 1119

Thanks for the question. Based on the documentation you should be able to use the redirectTo flag withresetPasswordForEmail as well.

Based on the docs you might want to try doing

supabase.auth.api.resetPasswordForEmail('[email protected]', { redirectTo: 'https://myspecialwebsite/redirect' })

rather than

supabase.auth.api.resetPasswordForEmail({ email }, { redirectTo: 'http://localhost:3000/recover' })

The key difference here is that email is passed in as a string param rather than an object -- it might be clearer if you refer directly to the source

I'm not sure of the exact use case but you can also take a look at generating a custom link via the admin endpoint

Hope this helps in some way

Upvotes: 3

Related Questions