File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,6 +89,36 @@ describe('handle', () => {
8989 expect ( res . body ) . toBe ( 'https://hono.dev/test-path' )
9090 } )
9191
92+ it ( 'Should preserve all values of a multi-value request header' , async ( ) => {
93+ const app = new Hono ( )
94+ app . get ( '/test-path' , ( c ) => c . text ( c . req . header ( 'x-forwarded-for' ) ?? '' ) )
95+ const handler = handle ( app )
96+
97+ const event : CloudFrontEdgeEvent = {
98+ Records : [
99+ {
100+ cf : {
101+ ...cloudFrontEdgeEvent . Records [ 0 ] . cf ,
102+ request : {
103+ ...cloudFrontEdgeEvent . Records [ 0 ] . cf . request ,
104+ headers : {
105+ host : [ { key : 'Host' , value : 'hono.dev' } ] ,
106+ 'x-forwarded-for' : [
107+ { key : 'X-Forwarded-For' , value : '10.0.0.1' } ,
108+ { key : 'X-Forwarded-For' , value : '192.168.1.1' } ,
109+ { key : 'X-Forwarded-For' , value : '203.0.113.55' } ,
110+ ] ,
111+ } ,
112+ } ,
113+ } ,
114+ } ,
115+ ] ,
116+ }
117+
118+ const res = await handler ( event )
119+ expect ( res . body ) . toBe ( '10.0.0.1, 192.168.1.1, 203.0.113.55' )
120+ } )
121+
92122 it ( 'Should expose async handler arity compatible with NODEJS_24_X' , ( ) => {
93123 const app = new Hono ( )
94124 const handler = handle ( app )
Original file line number Diff line number Diff line change @@ -159,7 +159,7 @@ const createRequest = (event: CloudFrontEdgeEvent): Request => {
159159
160160 const headers = new Headers ( )
161161 Object . entries ( event . Records [ 0 ] . cf . request . headers ) . forEach ( ( [ k , v ] ) => {
162- v . forEach ( ( header ) => headers . set ( k , header . value ) )
162+ v . forEach ( ( header ) => headers . append ( k , header . value ) )
163163 } )
164164
165165 const requestBody = event . Records [ 0 ] . cf . request . body
You can’t perform that action at this time.
0 commit comments