mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix: AWS credential signing http request - convert form to body (#14060)
Co-authored-by: Dana <152518854+dana-gill@users.noreply.github.com>
This commit is contained in:
@@ -476,13 +476,29 @@ export class Aws implements ICredentialType {
|
||||
|
||||
path = endpoint.pathname + endpoint.search;
|
||||
|
||||
// ! aws4.sign *must* have the body to sign, but we might have .form instead of .body
|
||||
const requestWithForm = requestOptions as unknown as { form?: Record<string, string> };
|
||||
let bodyContent = body !== '' ? body : undefined;
|
||||
let contentTypeHeader: string | undefined = undefined;
|
||||
if (requestWithForm.form) {
|
||||
const params = new URLSearchParams();
|
||||
for (const key in requestWithForm.form) {
|
||||
params.append(key, requestWithForm.form[key]);
|
||||
}
|
||||
bodyContent = params.toString();
|
||||
contentTypeHeader = 'application/x-www-form-urlencoded';
|
||||
}
|
||||
|
||||
const signOpts = {
|
||||
...requestOptions,
|
||||
headers: requestOptions.headers ?? {},
|
||||
headers: {
|
||||
...(requestOptions.headers ?? {}),
|
||||
...(contentTypeHeader && { 'content-type': contentTypeHeader }),
|
||||
},
|
||||
host: endpoint.host,
|
||||
method,
|
||||
path,
|
||||
body: body !== '' ? body : undefined,
|
||||
body: bodyContent,
|
||||
region,
|
||||
} as Request;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user