@@ -14,7 +14,10 @@ import {
14
14
* It will delete the header from response if the value is falsely
15
15
*/
16
16
export function setHeaders ( res : SWRResponse , headers : SWRHeader ) {
17
- let nextRes = res . clone ( ) ;
17
+ let nextRes = new Response ( res . clone ( ) . body , {
18
+ status : res . status ,
19
+ headers : res . headers ,
20
+ } ) ;
18
21
19
22
for ( let headersKey in headers ) {
20
23
let headerValue = headers [ headersKey ] ;
@@ -100,7 +103,10 @@ export function clientCacheControl(cacheControl: SWRCacheControl) {
100
103
return value . join ( ', ' ) ;
101
104
}
102
105
103
- export function edgeCacheControl ( cacheControl : SWRCacheControl , type : 'error' | 'success' ) : string {
106
+ export function edgeCacheControl (
107
+ cacheControl : SWRCacheControl ,
108
+ type : 'error' | 'success' ,
109
+ ) : string {
104
110
let value : string [ ] = [ ] ;
105
111
106
112
if ( cacheControl [ 'public' ] !== undefined ) {
@@ -110,7 +116,10 @@ export function edgeCacheControl(cacheControl: SWRCacheControl, type: 'error' |
110
116
}
111
117
112
118
let maxAge = Number ( cacheControl [ 's-maxage' ] || cacheControl [ 'max-age' ] || 0 ) ;
113
- let staleUntil = cacheControl [ type === 'success' ? 'stale-while-revalidate' : 'stale-if-error' ] ;
119
+ let staleUntil =
120
+ cacheControl [
121
+ type === 'success' ? 'stale-while-revalidate' : 'stale-if-error'
122
+ ] ;
114
123
115
124
// when null stale forever
116
125
// when undefined means content should not stale
0 commit comments