CORS Issue with better-auth in NestJS and Next Setup
Hey everyone,
I'm setting up authentication in my NestJS app using better-auth with a PostgreSQL database via Prisma. Everything seems to be correctly configured, but I'm running into a CORS issue when trying to sign up a user from my next front end.
Error Message
Access to XMLHttpRequest at 'http://localhost:3050/api/auth/sign-up/email' from origin 'http://localhost:3000' has been blocked by CORS policy: ** My Setup** **NestJS Backend (`main.ts`)**
Access to XMLHttpRequest at 'http://localhost:3050/api/auth/sign-up/email' from origin 'http://localhost:3000' has been blocked by CORS policy: ** My Setup** **NestJS Backend (`main.ts`)**
typescript async function bootstrap() { const app = await NestFactory.create(AppModule);
app.use('/api/auth', toNodeHandler(auth)); // Using better-auth middleware
Question Is there anything I need to add to my better-auth configuration to properly handle CORS? Is there an additional middleware required in NestJS for better-auth to work with CORS?