How to implement a custom response interceptor with Nest Better Auth library?
I'm using the Nest Better Auth library and need help implementing a custom interceptor to transform the library's default response format to match my application's standardized response structure.
Current Issue
The Better Auth library returns responses in this format:
or
I need to transform these responses to match my API's standard format:
What I've Tried
- Interceptors
- Exception filters
- Middleware
Questions
How can I intercept Better Auth responses before they're sent to the client?
Is there a built-in way to customize the response format in Better Auth, or do I need to wrap all endpoints?
Can you provide an example of a working interceptor that transforms Better Auth responses?
Environment:
NestJS version: 11.0.1
Better Auth version:  ^1.3.16
@thallesp/nestjs-better-auth: ^2.0.0
GitHub
GitHub - ThallesP/nestjs-better-auth: Easily add authentication to ...
Easily add authentication to your project. Contribute to ThallesP/nestjs-better-auth development by creating an account on GitHub.
0 Replies