Skip to content

Commit 00b6e2d

Browse files
committed
refactor: improve secure cookie handling in getAuthSession function
1 parent 605443f commit 00b6e2d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/server/model/auth.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,14 @@ export const authConfig: Omit<AuthConfig, 'raw'> = {
144144
*/
145145
export async function getAuthSession(
146146
req: IncomingMessage,
147-
secure = false
147+
_secure = false
148148
): Promise<Session | null> {
149+
const cookieStr = req.headers.cookie ?? '';
150+
151+
// Not cool
152+
const secure = cookieStr.includes('__Secure-authjs.session-token')
153+
? true
154+
: false;
149155
const protocol = secure ? 'https:' : 'http:';
150156
const url = createActionURL(
151157
'session',

0 commit comments

Comments
 (0)