nextjs + nestjs
i have a nextjs app with better auth setup.
what would be the best way to handle auth verifcation on the side of the nestjs backend ?
Solution:Jump to solution
Hey, there is https://github.com/better-auth/better-auth/pull/1548 coming, but there is also comment from user juandl , where he explains how he implemented it.
GitHub
feat: nestjs support by ThallesP · Pull Request #1548 · better-au...
Adds support for the NestJS framework
The PR adds full support for NestJS with decorators, guards, and a module for a seamless integration.
Here's some examples:
import { NestFactory } from...
7 Replies
Solution
Hey, there is https://github.com/better-auth/better-auth/pull/1548 coming, but there is also comment from user juandl , where he explains how he implemented it.
GitHub
feat: nestjs support by ThallesP · Pull Request #1548 · better-au...
Adds support for the NestJS framework
The PR adds full support for NestJS with decorators, guards, and a module for a seamless integration.
Here's some examples:
import { NestFactory } from...
yes i saw it but my problem comes from the fact that i handle auth on nextjs first (localhost:3001) and then i just want to access the session on the nestjs app (port 3000)
i saw this https://www.better-auth.com/docs/concepts/cookies#cross-subdomain-cookies
but i am not sure, will this only work in prod ?
Cookies | Better Auth
Learn how cookies are used in Better Auth.
thanks btw
Hello, I'm in exactly the same scenario as you. May I ask if you finally got it resolved? I tried the NestJS solution, but it didn't work—the API keeps returning a 401 error.,https://www.better-auth.com/docs/integrations/nestjs
NestJS Integration | Better Auth
Integrate Better Auth with NestJS.
yes i did ahah it was a long time ago
i dont quite remember how I fixed it I think it was mostly cross sites cookies and just setup settings
Well, it took me a long time, but I finally got it running successfully. This Next.js + Nest.js solution is really great to use, and I'm utilizing both the web and a browser extension as clients simultaneously.
Hello @Meepo and @zay ! Thank you very much for interacting in here. I'm exactly at the same scenario, facing 401 if I try to call my nestjs api using betterauth token as authorization header.
Can you guys detail how is the setup done for this interaction? I use the same DB for betterauth, also tried the same secret. Is sharing secret necessary too?