File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,10 @@ export function transferCacheInterceptorFn(
100
100
// POST requests are allowed either globally or at request level
101
101
( requestMethod === 'POST' && ! globalOptions . includePostRequests && ! requestOptions ) ||
102
102
( requestMethod !== 'POST' && ! ALLOWED_METHODS . includes ( requestMethod ) ) ||
103
- requestOptions === false || //
103
+ // Do not cache request that require authorization
104
+ req . headers . has ( 'authorization' ) ||
105
+ req . headers . has ( 'proxy-authorization' ) ||
106
+ requestOptions === false ||
104
107
globalOptions . filter ?.( req ) === false
105
108
) {
106
109
return next ( req ) ;
Original file line number Diff line number Diff line change @@ -248,6 +248,22 @@ describe('TransferCache', () => {
248
248
makeRequestAndExpectNone ( '/test-2?foo=1' , 'POST' , { transferCache : true } ) ;
249
249
} ) ;
250
250
251
+ it ( 'should not cache request that requires authorization' , async ( ) => {
252
+ makeRequestAndExpectOne ( '/test-auth' , 'foo' , {
253
+ headers : { Authorization : 'Basic YWxhZGRpbjpvcGVuc2VzYW1l' } ,
254
+ } ) ;
255
+
256
+ makeRequestAndExpectOne ( '/test-auth' , 'foo' ) ;
257
+ } ) ;
258
+
259
+ it ( 'should not cache request that requires proxy authorization' , async ( ) => {
260
+ makeRequestAndExpectOne ( '/test-auth' , 'foo' , {
261
+ headers : { 'Proxy-Authorization' : 'Basic YWxhZGRpbjpvcGVuc2VzYW1l' } ,
262
+ } ) ;
263
+
264
+ makeRequestAndExpectOne ( '/test-auth' , 'foo' ) ;
265
+ } ) ;
266
+
251
267
describe ( 'caching with global setting' , ( ) => {
252
268
beforeEach (
253
269
withBody ( '<test-app-http></test-app-http>' , ( ) => {
You can’t perform that action at this time.
0 commit comments