how i can change redirect url for reset password

if (!rateLimitCheck.allowed) {
return NextResponse.json(
{
error: 'Too many requests. Please wait a moment before trying again.',
remainingTime: rateLimitCheck.remainingTime,
},
{ status: 429 }
);
}


const supabase = createAdminClient();
const { data: linkData, error: linkError } = await supabase.auth.admin.generateLink({
type: 'recovery',
email,
});

if (linkError || !linkData.properties?.action_link) {
console.error('generateLink error:', linkError);
return NextResponse.json(
{
error: linkError?.message || 'Failed to generate password update link',
},
{ status: 500 }
);
}

const recoveryLink = linkData.properties.action_link;


const { data: emailData, error: emailError } = await resend.emails.send({
from: 'onboarding@resend.dev',
to: email,
subject: 'Reset your password',
react: VerificationEmail({
otp: recoveryLink,
isPasswordReset: true,
}),
});

if (emailError) {
console.error('Resend error:', emailError);
return NextResponse.json(
{ error: emailError.message },
{ status: 500 }
);
}

data = emailData;
break;
if (!rateLimitCheck.allowed) {
return NextResponse.json(
{
error: 'Too many requests. Please wait a moment before trying again.',
remainingTime: rateLimitCheck.remainingTime,
},
{ status: 429 }
);
}


const supabase = createAdminClient();
const { data: linkData, error: linkError } = await supabase.auth.admin.generateLink({
type: 'recovery',
email,
});

if (linkError || !linkData.properties?.action_link) {
console.error('generateLink error:', linkError);
return NextResponse.json(
{
error: linkError?.message || 'Failed to generate password update link',
},
{ status: 500 }
);
}

const recoveryLink = linkData.properties.action_link;


const { data: emailData, error: emailError } = await resend.emails.send({
from: 'onboarding@resend.dev',
to: email,
subject: 'Reset your password',
react: VerificationEmail({
otp: recoveryLink,
isPasswordReset: true,
}),
});

if (emailError) {
console.error('Resend error:', emailError);
return NextResponse.json(
{ error: emailError.message },
{ status: 500 }
);
}

data = emailData;
break;
its send a url but with redirect url i don't know how i can set it
1 Reply
silentworks
silentworks3w ago
How you can set which redirect URL? Do you mean the redirectTo that you would normally get with methods such as .signInWithOtp? If you look at the reference docs for the .generateLink https://supabase.com/docs/reference/javascript/auth-admin-generatelink and expand the options you will see how to set this there.

Did you find this page helpful?