File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,14 @@ describe('Proxy Middleware', () => {
36
36
} ,
37
37
} )
38
38
)
39
+ } else if ( req . url === 'https://example.com/set-cookie' ) {
40
+ return Promise . resolve (
41
+ new Response ( 'ok' , {
42
+ headers : {
43
+ 'Set-Cookie' : 'test=123' ,
44
+ } ,
45
+ } )
46
+ )
39
47
}
40
48
return Promise . resolve ( new Response ( 'not found' , { status : 404 } ) )
41
49
} )
@@ -153,5 +161,23 @@ describe('Proxy Middleware', () => {
153
161
154
162
expect ( res . headers . get ( 'Transfer-Encoding' ) ) . toBeNull ( )
155
163
} )
164
+
165
+ it ( 'modify header' , async ( ) => {
166
+ const app = new Hono ( )
167
+ app . get ( '/proxy/:path' , ( c ) =>
168
+ proxy ( `https://example.com/${ c . req . param ( 'path' ) } ` , {
169
+ headers : {
170
+ 'Set-Cookie' : 'test=123' ,
171
+ } ,
172
+ } ) . then ( ( res ) => {
173
+ res . headers . delete ( 'Set-Cookie' )
174
+ res . headers . set ( 'X-Response-Id' , '456' )
175
+ return res
176
+ } )
177
+ )
178
+ const res = await app . request ( '/proxy/set-cookie' )
179
+ expect ( res . headers . get ( 'Set-Cookie' ) ) . toBeNull ( )
180
+ expect ( res . headers . get ( 'X-Response-Id' ) ) . toBe ( '456' )
181
+ } )
156
182
} )
157
183
} )
You can’t perform that action at this time.
0 commit comments