mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user