exchangeCodeForSession not working

Why can I not create a session with that code. I've tried everything. Someone please help me.

Example url: http://localhost:3000/reset-password?code=558dd56e-417a-4c42-a7a7-43b8d978f765

AuthApiError: invalid request: both auth code and code verifier should be non-empty
at handleError (fetch.ts:102:9)
at async _handleRequest (fetch.ts:195:5)
at async _request (fetch.ts:157:16)
at async SupabaseAuthClient._exchangeCodeForSession (GoTrueClient.ts:868:31)

    const handleCode = async () => {
        try {
            const code = searchParams.get("code");
            console.log("code", code);

            const { data, error } = await supabaseBrowserClient.auth.exchangeCodeForSession(code);
            console.log(data, error);

            if (error) throw error;
            setLoading(false);
        } catch (error) {
            console.log("Failed to make session");

            console.log(error);
        }
    };

    useEffect(() => {
        handleCode();
    }, []);



export async function resetUserPasswordByID(userID, eMail) {
    try {
        await requirePermission(process.env.ADMIN_PERMISSION_ID);
        const supabaseClient = await createClient();
        await supabaseClient.auth.admin.updateUserById(userID, {
            user_metadata: { password_set: false },
            password: v4(),
        });
        await supabaseClient.auth.resetPasswordForEmail(eMail, {
            redirectTo: "http://localhost:3000/reset-password",
        });

        revalidatePath("/admin/users");
    } catch (error) {
        console.log(error);
        throw new Error("Failed to reset user password");
    }
}
Was this page helpful?