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(dbAuth): Don't use Multi Value Headers on Vercel #11718

Merged
merged 6 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 3 additions & 0 deletions .changesets/11718.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- fix(dbAuth): Don't use Multi Value Headers on Vercel (#11718) by @Tobbe

Fixes a regression regarding dbAuth on Vercel introduced in RW 8
13 changes: 11 additions & 2 deletions packages/auth-providers/dbAuth/api/src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,21 @@ export function getDbAuthResponseBuilder(
const setCookieHeaders = response.headers?.getSetCookie() || []

if (setCookieHeaders.length > 0) {
if ('multiValueHeaders' in event) {
delete headers['set-cookie']
delete headers['Set-Cookie']

// `'multiValueHeaders' in event` is true for both Netlify and Vercel
// but only Netlify actually supports it. Vercel will just ignore it
// https://github.com/vercel/vercel/issues/7820
if ('multiValueHeaders' in event && !('x-vercel-id' in headers)) {
Tobbe marked this conversation as resolved.
Show resolved Hide resolved
dbAuthResponse.multiValueHeaders = {
// Netlify wants 'Set-Cookie' headers to be capitalized
// https://github.com/redwoodjs/redwood/pull/10889
'Set-Cookie': setCookieHeaders,
}
delete headers['set-cookie']
} else {
// If we do this for Netlify the lambda function will throw an error
// https://github.com/redwoodjs/redwood/pull/10889
headers['set-cookie'] = setCookieHeaders
}
}
Expand Down
Loading