fix: BetterAuth 500 - request.headers.get is not a function (Express/Web API incompatibility) #410
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The BetterAuth integration crashes with a 500 error when any
/auth/*endpoint is hit. The root cause is a request object incompatibility between BetterAuth and NestJS/Express.Error
Root Cause
BetterAuth expects a Web API
Requestobject (Fetch API standard) which hasheaders.get('name'). NestJS/Express passes anIncomingMessageobject which usesheaders['name']property access instead of.get().The BetterAuth handler in the auth module needs to convert the Express request into a Web API
Request(or a compatible adapter) before passing it to BetterAuth.Steps to Reproduce
OIDC_ENABLED=true/auth/signin/authentikendpointExpected Behavior
The endpoint should redirect to Authentik for OIDC authentication flow.
Affected Files
apps/api/src/auth/— Auth module/controller where BetterAuth is integratedEnvironment
better-auth@1.4.17