From 2877f22dfb301c8d16069090c4b994091d51d5c3 Mon Sep 17 00:00:00 2001 From: Esdras Renan Date: Fri, 10 Oct 2025 09:46:45 -0300 Subject: [PATCH] chore(auth): add trustedOrigins to allow localhost in dev without impacting production --- src/lib/auth.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lib/auth.ts b/src/lib/auth.ts index 2304f2b..e1f53cd 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -8,6 +8,17 @@ import { prisma } from "./prisma" export const auth = betterAuth({ secret: env.BETTER_AUTH_SECRET, baseURL: env.BETTER_AUTH_URL, + // Permite login tanto no domínio de produção quanto no localhost em DEV + trustedOrigins: Array.from( + new Set( + [ + env.BETTER_AUTH_URL, + env.NEXT_PUBLIC_APP_URL, + process.env.NODE_ENV !== "production" ? "http://localhost:3000" : undefined, + process.env.NODE_ENV !== "production" ? "http://127.0.0.1:3000" : undefined, + ].filter(Boolean) as string[] + ) + ), database: prismaAdapter(prisma, { provider: "sqlite", }),