Skip to content

Commit e9ac11b

Browse files
fix: respect host in getServerSession (#3179)
1 parent ba39efb commit e9ac11b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { NextAuthAction } from "../lib/types"
99

1010
export interface IncomingRequest {
1111
/** @default "http://localhost:3000" */
12-
host?: string
12+
host: string
1313
method: string
1414
cookies?: Record<string, any>
1515
headers?: Record<string, any>

src/next/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async function NextAuthNextHandler(
2525
return res.status(500).send(error.message)
2626
}
2727

28-
const host = process.env.NEXTAUTH_URL ?? process.env.VERCEL_URL
28+
const host = (process.env.NEXTAUTH_URL ?? process.env.VERCEL_URL) as string
2929
if (!host) logger.warn("NEXTAUTH_URL")
3030

3131
const {
@@ -105,6 +105,7 @@ export async function getServerSession(
105105
const session = await NextAuthHandler<Session | {}>({
106106
options,
107107
req: {
108+
host: (process.env.NEXTAUTH_URL ?? process.env.VERCEL_URL) as string,
108109
action: "session",
109110
method: "GET",
110111
cookies: context.req.cookies,

0 commit comments

Comments
 (0)