From 130facb440929fc43c8f84c75375d2be1f452775 Mon Sep 17 00:00:00 2001 From: Anwarul Islam Date: Wed, 21 May 2025 21:32:07 +0600 Subject: [PATCH] fix: include request body to AWS V4 signer in effective request functions (#5084) --- packages/hoppscotch-cli/src/utils/pre-request.ts | 3 +++ packages/hoppscotch-common/src/helpers/utils/EffectiveURL.ts | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/packages/hoppscotch-cli/src/utils/pre-request.ts b/packages/hoppscotch-cli/src/utils/pre-request.ts index f8bca56e..4f012278 100644 --- a/packages/hoppscotch-cli/src/utils/pre-request.ts +++ b/packages/hoppscotch-cli/src/utils/pre-request.ts @@ -202,8 +202,11 @@ export async function getEffectiveRESTRequest( const amzDate = currentDate.toISOString().replace(/[:-]|\.\d{3}/g, ""); const { method, endpoint } = request; + const body = getFinalBodyFromRequest(request, resolvedVariables); + const signer = new AwsV4Signer({ method, + body: E.isRight(body) ? body.right?.toString() : undefined, datetime: amzDate, signQuery: addTo === "QUERY_PARAMS", accessKeyId: parseTemplateString( diff --git a/packages/hoppscotch-common/src/helpers/utils/EffectiveURL.ts b/packages/hoppscotch-common/src/helpers/utils/EffectiveURL.ts index a346b127..2ff0e82e 100644 --- a/packages/hoppscotch-common/src/helpers/utils/EffectiveURL.ts +++ b/packages/hoppscotch-common/src/helpers/utils/EffectiveURL.ts @@ -222,8 +222,12 @@ export const getComputedAuthHeaders = async ( const currentDate = new Date() const amzDate = currentDate.toISOString().replace(/[:-]|\.\d{3}/g, "") const { method, endpoint } = req as HoppRESTRequest + + const body = getFinalBodyFromRequest(request, envVars) + const signer = new AwsV4Signer({ method: method, + body: body?.toString(), datetime: amzDate, accessKeyId: parseTemplateString(request.auth.accessKey, envVars), secretAccessKey: parseTemplateString(request.auth.secretKey, envVars),