diff --git a/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts b/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts index 880df24661..ca2585b7f4 100644 --- a/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts @@ -748,9 +748,7 @@ export class HttpRequestV3 implements INodeType { typeOptions: { multipleValues: false, }, - default: { - redirect: {}, - }, + default: { redirect: {} }, options: [ { displayName: 'Redirect', @@ -779,6 +777,56 @@ export class HttpRequestV3 implements INodeType { ], }, ], + displayOptions: { + show: { + '@version': [1, 2, 3], + }, + }, + }, + { + displayName: 'Redirects', + name: 'redirect', + placeholder: 'Add Redirect', + type: 'fixedCollection', + typeOptions: { + multipleValues: false, + }, + default: { + redirect: {}, + }, + options: [ + { + displayName: 'Redirect', + name: 'redirect', + values: [ + { + displayName: 'Follow Redirects', + name: 'followRedirects', + type: 'boolean', + default: true, + noDataExpression: true, + description: 'Whether to follow all redirects', + }, + { + displayName: 'Max Redirects', + name: 'maxRedirects', + type: 'number', + displayOptions: { + show: { + followRedirects: [true], + }, + }, + default: 21, + description: 'Max number of redirects to follow', + }, + ], + }, + ], + displayOptions: { + hide: { + '@version': [1, 2, 3], + }, + }, }, { displayName: 'Response', @@ -984,7 +1032,6 @@ export class HttpRequestV3 implements INodeType { 'keypair', ) as string; const jsonHeadersParameter = this.getNodeParameter('jsonHeaders', itemIndex, '') as string; - const { redirect, batching, @@ -1038,13 +1085,14 @@ export class HttpRequestV3 implements INodeType { if (autoDetectResponseFormat || fullResponse) { requestOptions.resolveWithFullResponse = true; } + const defaultRedirect = nodeVersion >= 4 && redirect === undefined; - if (redirect?.redirect?.followRedirects) { + if (redirect?.redirect?.followRedirects || defaultRedirect) { requestOptions.followRedirect = true; requestOptions.followAllRedirects = true; } - if (redirect?.redirect?.maxRedirects) { + if (redirect?.redirect?.maxRedirects || defaultRedirect) { requestOptions.maxRedirects = redirect?.redirect?.maxRedirects; }