From b436606712aa1c1df3c801359fdb119707565db9 Mon Sep 17 00:00:00 2001 From: Nick Nisi Date: Thu, 27 Feb 2025 16:37:15 -0600 Subject: [PATCH] fix: getAuthorizationUrl calls don't always include custom redirectUri set in middleware (#209) --- src/session.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/session.ts b/src/session.ts index 43846cf..02287b5 100644 --- a/src/session.ts +++ b/src/session.ts @@ -126,6 +126,12 @@ async function updateSession( // `pathname` to be able to return the users where they came from before sign-in newRequestHeaders.set('x-url', request.url); + if (options.redirectUri) { + // Store the redirect URI in a custom header, so we always have access to it and so that subsequent + // calls to `getAuthorizationUrl` will use the same redirect URI + newRequestHeaders.set('x-redirect-uri', options.redirectUri); + } + newRequestHeaders.delete(sessionHeaderName); if (!session) {