feat(n8n Form Trigger Node): Improvements (#7571)

Github issue / Community forum post (link here to close automatically):

---------

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
Co-authored-by: Giulio Andreini <andreini@netseven.it>
This commit is contained in:
Michael Kret
2023-12-13 17:00:51 +02:00
committed by GitHub
parent 26f0d57f5f
commit 953a58f18b
37 changed files with 1163 additions and 496 deletions

View File

@@ -46,6 +46,10 @@ export class RespondToWebhook implements INodeType {
name: 'No Data',
value: 'noData',
},
{
name: 'Redirect',
value: 'redirect',
},
{
name: 'Text',
value: 'text',
@@ -66,6 +70,21 @@ export class RespondToWebhook implements INodeType {
},
default: '',
},
{
displayName: 'Redirect URL',
name: 'redirectURL',
type: 'string',
required: true,
displayOptions: {
show: {
respondWith: ['redirect'],
},
},
default: '',
placeholder: 'e.g. http://www.n8n.io',
description: 'The URL to redirect to',
validateType: 'url',
},
{
displayName: 'Response Body',
name: 'responseBody',
@@ -202,6 +221,7 @@ export class RespondToWebhook implements INodeType {
}
}
let statusCode = (options.responseCode as number) || 200;
let responseBody: IN8nHttpResponse | Readable;
if (respondWith === 'json') {
const responseBodyParameter = this.getNodeParameter('responseBody', 0) as string;
@@ -250,6 +270,9 @@ export class RespondToWebhook implements INodeType {
if (!headers['content-type']) {
headers['content-type'] = binaryData.mimeType;
}
} else if (respondWith == 'redirect') {
headers.location = this.getNodeParameter('redirectURL', 0) as string;
statusCode = (options.responseCode as number) ?? 307;
} else if (respondWith !== 'noData') {
throw new NodeOperationError(
this.getNode(),
@@ -260,7 +283,7 @@ export class RespondToWebhook implements INodeType {
const response: IN8nHttpFullResponse = {
body: responseBody,
headers,
statusCode: (options.responseCode as number) || 200,
statusCode,
};
this.sendResponse(response);