Overriding TOTP Period Causes Unauthorized / Invalid Two-Factor Cookie Error

When I override the default TOTP period (e.g. from 30 seconds to 60 seconds) in the Better Auth 2FA TOTP plugin configuration. The attempt to verify totp code end up in resulting in Unauthorized response and an Invalid two-factor cookie message. If you dont override the default period. The code works fine.



To Reproduce


export const auth = betterAuth({
plugins: [
    twoFactor({
      totpOptions: {
        period: 60
      },
    },
  ],
})


I was using Sveltekit when i encountered this error
image.png
Was this page helpful?