Skip to content

Commit e914689

Browse files
committed
fix: new headers object as its immutable
1 parent 47440c0 commit e914689

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/client/src/client.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,16 @@ export class DefaultDelegatedRoutingV1HttpApiClient implements DelegatedRoutingV
409409
const requestPromise = fetch(url, options).then(async response => {
410410
// Only cache successful GET requests
411411
if (this.cache != null && response.ok && requestMethod === 'GET') {
412-
// Create a new response with expiration header
413-
const cachedResponse = response.clone()
414412
const expires = Date.now() + this.cacheTTL
415-
cachedResponse.headers.set('x-cache-expires', expires.toString())
413+
const headers = new Headers(response.headers)
414+
headers.set('x-cache-expires', expires.toString())
415+
416+
// Create a new response with expiration header
417+
const cachedResponse = new Response(response.clone().body, {
418+
status: response.status,
419+
statusText: response.statusText,
420+
headers
421+
})
416422

417423
await this.cache.put(url, cachedResponse)
418424
}

0 commit comments

Comments
 (0)