File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
packages/open-next/src/http Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -12,14 +12,24 @@ export const parseHeaders = (
12
12
if ( value === undefined ) {
13
13
continue ;
14
14
}
15
- // Next can return an Array for the Location header
16
- // We dont want to merge that into a comma-separated string
17
- // See: https://github.com/opennextjs/opennextjs-cloudflare/issues/875#issuecomment-3258248276
18
- if ( key . toLowerCase ( ) === "location" && Array . isArray ( value ) ) {
19
- result [ key . toLowerCase ( ) ] = value [ 0 ] ;
15
+ const keyLower = key . toLowerCase ( ) ;
16
+ /**
17
+ * Next can return an Array for the Location header
18
+ * We dont want to merge that into a comma-separated string
19
+ * If they are the same just return one of them
20
+ * Otherwise return the last one
21
+ * See: https://github.com/opennextjs/opennextjs-cloudflare/issues/875#issuecomment-3258248276
22
+ * and https://github.com/opennextjs/opennextjs-aws/pull/977#issuecomment-3261763114
23
+ */
24
+ if ( keyLower === "location" && Array . isArray ( value ) ) {
25
+ if ( value [ 0 ] === value [ 1 ] ) {
26
+ result [ keyLower ] = value [ 0 ] ;
27
+ } else {
28
+ result [ keyLower ] = value [ value . length - 1 ] ;
29
+ }
20
30
continue ;
21
31
}
22
- result [ key . toLowerCase ( ) ] = convertHeader ( value ) ;
32
+ result [ keyLower ] = convertHeader ( value ) ;
23
33
}
24
34
25
35
return result ;
You can’t perform that action at this time.
0 commit comments