Description
Hi, thanks for the great library! I think I’ve found a bug – translations are not applied to errors from the captcha plugin.
I’m using a custom getLocale function, but it doesn’t seem to be called when captcha errors occur. With standard better-auth errors, everything works as expected: getLocale is called and returns the correct locale and the plugin applies the translation to the error.
Expected behavior
When the captcha plugin throws an error (VERIFICATION_FAILED, MISSING_RESPONSE or UNKNOWN_ERROR), it should be returned in the detected language.
Actual behavior
VERIFICATION_FAILED, MISSING_RESPONSE and UNKNOWN_ERROR are always returned in English.
Versions
better-auth: 1.5.6
better-auth-localization: 3.0.0
Localization setup
Better-auth plugins are configured as follows:
plugins: [
customSession(),
captchaPlugin({
provider: 'cloudflare-turnstile',
secretKey: process.env.TURNSTILE_SECRET_KEY!
}),
username(),
localizationPlugin({
defaultLocale: 'default',
fallbackLocale: 'default',
getLocale: getLocale
})
]
Steps to reproduce
Minimal example:
// Backend
export const auth = betterAuth({
database: drizzleAdapter(db, { provider: 'mysql', schema: authSchema }),
plugins: [
captcha({
provider: 'cloudflare-turnstile',
secretKey: '1x0000000000000000000000000000000AA' // Test key
}),
localization({
defaultLocale: 'default',
fallbackLocale: 'default',
getLocale: () => {
console.log('getLocale is called');
return 'ru-RU';
}
})
]
});
// Frontend (locale 'ru-RU' is sent with headers)
const response = await authClient.signUp.email({
email: 'test@test.com',
password: 'qwerty123'
});
console.log(response);
// {
// "data": null,
// "error": {
// "message": "Missing CAPTCHA response", // Not "Ответ CAPTCHA отсутствует"
// "code": "MISSING_RESPONSE",
// "status": 400,
// "statusText": "Bad Request"
// }
// }
Description
Hi, thanks for the great library! I think I’ve found a bug – translations are not applied to errors from the captcha plugin.
I’m using a custom getLocale function, but it doesn’t seem to be called when captcha errors occur. With standard better-auth errors, everything works as expected: getLocale is called and returns the correct locale and the plugin applies the translation to the error.
Expected behavior
When the captcha plugin throws an error (VERIFICATION_FAILED, MISSING_RESPONSE or UNKNOWN_ERROR), it should be returned in the detected language.
Actual behavior
VERIFICATION_FAILED, MISSING_RESPONSE and UNKNOWN_ERROR are always returned in English.
Versions
better-auth: 1.5.6
better-auth-localization: 3.0.0
Localization setup
Better-auth plugins are configured as follows:
Steps to reproduce
Minimal example: