Skip to content

Commit

Permalink
fix: add missing host in next-auth adapter (#4325)
Browse files Browse the repository at this point in the history
* fix: add missing host in next-auth adapter

* Create red-masks-drop.md

* Update .changeset/red-masks-drop.md
  • Loading branch information
siddhsuresh authored Apr 17, 2024
1 parent 22e402a commit 7755546
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/red-masks-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@blitzjs/auth": patch
"blitz": patch
---

fix: add missing host while initialising the next-auth adapter
4 changes: 2 additions & 2 deletions packages/blitz-auth/src/server/adapters/next-auth/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ export function NextAuthAdapter<P extends Provider[]>(
const {options, cookies} = await init({
// @ts-ignore
url: new URL(
// @ts-ignore
internalRequest.url!,
internalRequest.url,
process.env.APP_ORIGIN || process.env.BLITZ_DEV_SERVER_ORIGIN,
),
authOptions: config as unknown as AuthOptions,
host: internalRequest.url.host,
action,
providerId,
callbackUrl: req.body?.callbackUrl ?? (req.query?.callbackUrl as string),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ async function readJSONBody(
// prettier-ignore
const actions = [ "providers", "session", "csrf", "login", "signout", "callback", "verify-request", "error", "_log"]

export async function toInternalRequest(req: Request): Promise<RequestInternal | Error> {
export async function toInternalRequest(req: Request): Promise<
| (RequestInternal & {
url: URL
})
| Error
> {
try {
// TODO: url.toString() should not include action and providerId
// see init.ts
Expand All @@ -70,7 +75,6 @@ export async function toInternalRequest(req: Request): Promise<RequestInternal |
}

return {
//@ts-ignore
url,
action,
providerId,
Expand Down

0 comments on commit 7755546

Please sign in to comment.