@@ -295,12 +295,18 @@ export function getDbAuthResponseBuilder(
295
295
const setCookieHeaders = response . headers ?. getSetCookie ( ) || [ ]
296
296
297
297
if ( setCookieHeaders . length > 0 ) {
298
- if ( 'multiValueHeaders' in event ) {
298
+ delete headers [ 'set-cookie' ]
299
+ delete headers [ 'Set-Cookie' ]
300
+
301
+ if ( supportsMultiValueHeaders ( event ) ) {
299
302
dbAuthResponse . multiValueHeaders = {
303
+ // Netlify wants 'Set-Cookie' headers to be capitalized
304
+ // https://github.com/redwoodjs/redwood/pull/10889
300
305
'Set-Cookie' : setCookieHeaders ,
301
306
}
302
- delete headers [ 'set-cookie' ]
303
307
} else {
308
+ // If we do this for Netlify the lambda function will throw an error
309
+ // https://github.com/redwoodjs/redwood/pull/10889
304
310
headers [ 'set-cookie' ] = setCookieHeaders
305
311
}
306
312
}
@@ -309,6 +315,16 @@ export function getDbAuthResponseBuilder(
309
315
}
310
316
}
311
317
318
+ // `'multiValueHeaders' in event` is true for both Netlify and Vercel
319
+ // but only Netlify actually supports it. Vercel will just ignore it
320
+ // https://github.com/vercel/vercel/issues/7820
321
+ function supportsMultiValueHeaders ( event : APIGatewayProxyEvent | Request ) {
322
+ return (
323
+ 'multiValueHeaders' in event &&
324
+ ( ! event . headers || ! ( 'x-vercel-id' in event . headers ) )
325
+ )
326
+ }
327
+
312
328
export const extractHashingOptions = ( text : string ) : ScryptOptions => {
313
329
const [ _hash , ...options ] = text . split ( '|' )
314
330
0 commit comments