Skip to content

Commit af67508

Browse files
committed
chore: updated cookie config
1 parent acde9e6 commit af67508

5 files changed

Lines changed: 19 additions & 3 deletions

File tree

apps/api/src/app.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import trackRoutes from "@/routes/track/route";
1313
const createApp = (): Express => {
1414
const app: Express = express();
1515

16+
app.set("trust proxy", true);
17+
1618
app.use(cors(corsOptions));
1719

1820
app.all("/api/auth/*splat", toNodeHandler(auth));

apps/api/src/config/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import "dotenv/config";
22

33
export const env = {
44
PORT: process.env.PORT,
5+
NODE_ENV: process.env.NODE_ENV,
56
APP_URL: process.env.APP_URL,
67
FRONTEND_URL: process.env.FRONTEND_URL,
78
API_URL: process.env.API_URL,

apps/api/src/lib/auth/auth.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { prismaAdapter } from "better-auth/adapters/prisma";
44
import { env } from "@/config/env";
55
import { sendWelcomeEmail } from "@/lib/actions/email";
66

7+
const isProd = env.NODE_ENV === "production";
8+
79
export const auth = betterAuth({
810
database: prismaAdapter(db, {
911
provider: "postgresql",
@@ -14,6 +16,17 @@ export const auth = betterAuth({
1416
storeSessionInDatabase: true,
1517
preserveSessionInDatabase: true,
1618
},
19+
advanced: {
20+
useSecureCookies: isProd,
21+
cookies: {
22+
state: {
23+
attributes: {
24+
sameSite: isProd ? "none" : "lax",
25+
secure: isProd,
26+
},
27+
},
28+
},
29+
},
1730
socialProviders: {
1831
google: {
1932
clientId: env.GOOGLE_CLIENT_ID || "",

apps/web/app/providers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const queryClient = new QueryClient({
99
defaultOptions: {
1010
queries: {
1111
staleTime: 60 * 1000,
12-
gcTime: 1000 * 60 * 30, // 30 minutes
12+
gcTime: 1000 * 60 * 30,
1313
},
1414
},
1515
});

apps/web/config/env.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const env = {
22
apiBase: process.env.NEXT_PUBLIC_API_URL,
33
appBase: process.env.NEXT_PUBLIC_APP_URL,
4-
FLAGIX_SDK_API_KEY: process.env.FLAGIX_SDK_API_KEY,
5-
FLAGIX_SDK_BASE_URL: process.env.FLAGIX_SDK_BASE_URL,
4+
FLAGIX_SDK_API_KEY: process.env.NEXT_PUBLIC_FLAGIX_SDK_API_KEY,
5+
FLAGIX_SDK_BASE_URL: process.env.NEXT_PUBLIC_FLAGIX_SDK_BASE_URL,
66
};

0 commit comments

Comments
 (0)