File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
packages/s3-request-presigner/src Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -107,4 +107,12 @@ describe("s3 presigner", () => {
107107 expect ( signedHeaders ) . toContain ( "x-amz-server-side-encryption" ) ;
108108 expect ( signedHeaders ) . toContain ( "x-amz-server-side-encryption-customer-algorithm" ) ;
109109 } ) ;
110+
111+ it ( "should inject host header if not supplied" , async ( ) => {
112+ const signer = new S3RequestPresigner ( s3ResolvedConfig ) ;
113+ const signed = await signer . presign ( minimalRequest ) ;
114+ expect ( signed . headers ) . toMatchObject ( {
115+ host : minimalRequest . hostname ,
116+ } ) ;
117+ } ) ;
110118} ) ;
Original file line number Diff line number Diff line change @@ -43,6 +43,9 @@ export class S3RequestPresigner implements RequestPresigner {
4343 unhoistableHeaders . add ( header ) ;
4444 } ) ;
4545 requestToSign . headers [ SHA256_HEADER ] = UNSIGNED_PAYLOAD ;
46+ if ( ! requestToSign . headers [ "host" ] ) {
47+ requestToSign . headers . host = requestToSign . hostname ;
48+ }
4649 return this . signer . presign ( requestToSign , {
4750 expiresIn : 900 ,
4851 unsignableHeaders,
You can’t perform that action at this time.
0 commit comments