Bill
Bill
BABetter Auth
Created by Bill on 3/31/2025 in #help
Replace or override baseEndpoints
I want to replace the built in resetPassword endpoint
const authenticator = betterAuth({
plugins: [
{
id: 'plugin',
endpoints: {
resetPassword: createAuthEndpoint(
'/plugin/reset-password',
{
method: 'POST'
},
async ctx => {
return ctx.json({
message: 'reset password'
});
}
)
}
} satisfies BetterAuthPlugin
]
});

// Property 'resetPassword' does not exist on type 'InferAPI...
authenticator.api.resetPassword;
const authenticator = betterAuth({
plugins: [
{
id: 'plugin',
endpoints: {
resetPassword: createAuthEndpoint(
'/plugin/reset-password',
{
method: 'POST'
},
async ctx => {
return ctx.json({
message: 'reset password'
});
}
)
}
} satisfies BetterAuthPlugin
]
});

// Property 'resetPassword' does not exist on type 'InferAPI...
authenticator.api.resetPassword;
If the path is not /reset-password, it gives a type error
const authenticator = betterAuth({
plugins: [
{
id: 'plugin',
endpoints: {
resetPassword: createAuthEndpoint(
'/reset-password',
{
method: 'POST',
body: z.object({
token: z.string(),
newPassword: z.string(),
test: z.string()
})
},
async ctx => {
return ctx.json({
message: 'reset password'
});
}
)
}
} satisfies BetterAuthPlugin
]
});
const data = await authenticator.api.resetPassword({});
const authenticator = betterAuth({
plugins: [
{
id: 'plugin',
endpoints: {
resetPassword: createAuthEndpoint(
'/reset-password',
{
method: 'POST',
body: z.object({
token: z.string(),
newPassword: z.string(),
test: z.string()
})
},
async ctx => {
return ctx.json({
message: 'reset password'
});
}
)
}
} satisfies BetterAuthPlugin
]
});
const data = await authenticator.api.resetPassword({});
If the path is /reset-password it doesn't give a type error, but the return type is still the default { status: boolean }. If I remove body zod schema, data returns { message: string }
5 replies