Skip to content

Commit 6f448bc

Browse files
committed
fix(portal): unable to authenticate users due to cross site cookies not enabled
1 parent ffa692f commit 6f448bc

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

apps/portal/app/sessions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ const { getSession, commitSession, destroySession }
1919
{
2020
cookie: {
2121
name: '__session',
22-
secure: process.env.NODE_ENV === 'production',
22+
secure: true,
2323
secrets: [sessionSecret],
24-
sameSite: 'lax',
24+
sameSite: 'none',
2525
path: '/',
2626
httpOnly: true,
2727
},

libs/cms/auth/auth.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,22 @@ import {
33
} from 'better-auth';
44

55
export const auth = betterAuth({
6+
advanced: {
7+
crossSubDomainCookies: {
8+
enabled: true,
9+
domain: ".cuhacking.ca",
10+
},
11+
defaultCookieAttributes: {
12+
secure: true,
13+
httpOnly: true,
14+
sameSite: "none",
15+
partitioned: true,
16+
},
17+
},
618
socialProviders: {
719
linkedin: {
8-
clientId: process.env.LINKEDIN_CLIENT_ID,
9-
clientSecret: process.env.LINKEDIN_CLIENT_SECRET
20+
clientId: process.env.LINKEDIN_CLIENT_ID || '',
21+
clientSecret: process.env.LINKEDIN_CLIENT_SECRET || ''
1022
}
1123
},
1224

libs/db/collections/models/Users.ts

+5
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ export const Users: CollectionConfig = {
259259
slug: "users",
260260
// auth: true,
261261
auth: {
262+
cookies: {
263+
domain: process.env.NODE_ENV === 'development' ? 'localhost' : '.cuhacking.ca',
264+
sameSite: 'None',
265+
secure: true
266+
},
262267
disableLocalStrategy: {
263268
enableFields: true,
264269
optionalPassword: true,

0 commit comments

Comments
 (0)