Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(next-auth): cannot parse action at /session #10218

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions packages/next-auth/src/lib/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Auth, raw, skipCSRFCheck } from "@auth/core"
import {
Auth,
raw,
skipCSRFCheck,
createActionURL as createActionURLCore,
} from "@auth/core"
import { headers as nextHeaders, cookies } from "next/headers"
import { redirect } from "next/navigation"

Expand Down Expand Up @@ -120,16 +125,12 @@ export function createActionURL(
h: Headers | ReturnType<typeof headers>,
basePath?: string
): URL {
const envUrl = process.env.AUTH_URL ?? process.env.NEXTAUTH_URL
if (envUrl) {
const { origin, pathname } = new URL(envUrl)
const separator = pathname.endsWith("/") ? "" : "/"
return new URL(`${origin}${pathname}${separator}${action}`)
}
const host = h.get("x-forwarded-host") ?? h.get("host")
const protocol = h.get("x-forwarded-proto") === "http" ? "http" : "https"
// @ts-expect-error `basePath` value is default'ed to "/api/auth" in `setEnvDefaults`
const { origin, pathname } = new URL(basePath, `${protocol}://${host}`)
const separator = pathname.endsWith("/") ? "" : "/"
return new URL(`${origin}${pathname}${separator}${action}`)
return createActionURLCore(
action,
ThangHuuVu marked this conversation as resolved.
Show resolved Hide resolved
// @ts-expect-error `x-forwarded-proto` is not nullable, next-auth sets it by default
h.get("x-forwarded-proto"),
h,
process.env,
basePath
)
}
Loading