SupabaseS
Supabase2y ago
dave

Reset Password flow confusion/not working

I have a supabase/ssr + Remix project set up with the following versions:
@remix - 2.2.0 (node, express, react)
"@supabase/ssr": "^0.0.10",
"@supabase/supabase-js": "^2.39.0",
"react": "^18.2.0",


I've worked through the sign up and login flows and started to add the reset password flow to my app. I've created singleton objects for the server and browser client, both using @supabase/ssr like so:

createServerClient
export function getSupabaseWithHeaders({ request }: { request: Request }) {
  const cookies = parse(request.headers.get("Cookie") ?? "");
  const headers = new Headers();

  const supabase = createServerClient(
    process.env.DATABASE_URL!,
    process.env.SUPABASE_ANON_KEY!,
    {
      auth: {
        autoRefreshToken: false,
        persistSession: false,
        detectSessionInUrl: false,
      },
      cookies: {
        get(key) {
          return cookies[key];
        },
        set(key, value, options) {
          headers.append("Set-Cookie", serialize(key, value, options));
        },
        remove(key, options) {
          headers.append("Set-Cookie", serialize(key, "", options));
        },
      },
    },
  );

  return { supabase, headers };
}


createBrowserClient(env.DATABASE_URL!, env.SUPABASE_ANON_KEY!),


The email triggers just fine, I'm able to find it in inBucket and I get both the link and the OTP in the email. The (plaintext) email looks like this:
--------------
Reset password
--------------

Follow this link to reset the password for your user:

Reset password ( http://127.0.0.1:54321/auth/v1/verify?token=pkce_56c6bf5cf091e74770b21ffe167eb6af9b854c44cba8ec84b8b08ea8&type=recovery&redirect_to=http://127.0.0.1:3000/auth/update )

Alternatively, enter the code: 657886


Clicking the link redirects correctly and appends a ?code= param to the end. This is where I'm stuck - I assumed I should be calling exchangeCodeForSession with the code param since it seems to be auto-applied to the redirect, but I end up with the following error:

TypeError - Cannot read properties of null (reading 'split')


One thing I did notice was that the email template for Reset Password (in my supabase dashboard, not local) is different than what this flow is offering. So at this point, my question is:

Is the template being sent the wrong template? I would expect the reset password method to send the right URL for the flow. If it is the wrong template/link, how do I modify it to match what I have in my project dashboard?

I found this Github issue with the same error but not much else while looking around on discord/github/stackoverflow: https://github.com/supabase/supabase/issues/19896
GitHub
Bug report I confirm this is a bug with Supabase, not with my own application. I confirm I have searched the Docs, GitHub Discussions, and Discord. Describe the bug I am seeing TypeError - Cannot r...
Was this page helpful?