diff --git a/packages/nodes-base/credentials/Aws.credentials.ts b/packages/nodes-base/credentials/Aws.credentials.ts index e9fe9cbdc8..dc10c02ecf 100644 --- a/packages/nodes-base/credentials/Aws.credentials.ts +++ b/packages/nodes-base/credentials/Aws.credentials.ts @@ -276,7 +276,7 @@ export class Aws implements ICredentialType { let service = requestOptions.qs?.service as string; let path = requestOptions.qs?.path; const method = requestOptions.method; - const body = requestOptions.body; + let body = requestOptions.body; let region = credentials.region; const query = requestOptions.qs?.query as IDataObject; if (!requestOptions.baseURL && !requestOptions.url) { @@ -301,13 +301,13 @@ export class Aws implements ICredentialType { endpoint = new URL(endpointString!.replace('{region}', credentials.region as string) + path); } else { // If no endpoint is set, we try to decompose the path and use the default endpoint - const customUrl = new URL(requestOptions.baseURL! + requestOptions.url! + path); + const customUrl = new URL(`${requestOptions.baseURL!}${requestOptions.url}${path ?? ''}`); service = customUrl.hostname.split('.')[0] as string; region = customUrl.hostname.split('.')[1] as string; if (service === 'sts') { try { customUrl.searchParams.set('Action', 'GetCallerIdentity'); - customUrl.searchParams.append('Version', '2011-06-15'); + customUrl.searchParams.set('Version', '2011-06-15'); } catch (err) { console.log(err); } @@ -321,6 +321,10 @@ export class Aws implements ICredentialType { }); } + if (body && Object.keys(body).length === 0) { + body = ''; + } + path = endpoint.pathname + endpoint.search; const signOpts = {