Skip to content

Commit 4b8aa66

Browse files
authored
fix: use original accept encoding header to resolve s3 request signing issue (#729)
1 parent cd6a909 commit 4b8aa66

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/storage/protocols/s3/signature-v4.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import crypto from 'crypto'
22
import { ERRORS } from '@internal/errors'
3-
import { V4StreamingAlgorithm } from '@storage/protocols/s3/signature-v4-stream'
43

54
interface SignatureV4Options {
65
enforceRegion: boolean
@@ -440,6 +439,15 @@ export class SignatureV4 {
440439
return `${header}:${headerValue}`
441440
}
442441

442+
// cloudflare modifies accept-encoding header which causes signing to fail
443+
// instead use x-original-accept-encoding if available
444+
if (header === 'accept-encoding') {
445+
const originalEncoding = this.getHeader(request, 'x-original-accept-encoding')
446+
if (originalEncoding) {
447+
return `${header}:${originalEncoding}`
448+
}
449+
}
450+
443451
return `${header}:${this.getHeader(request, header)}`
444452
})
445453
.join('\n') + '\n'

0 commit comments

Comments
 (0)