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

@@ -2,7 +2,11 @@
import type { Request, Response } from 'express';
import { parse, stringify } from 'flatted';
import picocolors from 'picocolors';
import { ErrorReporterProxy as ErrorReporter, NodeApiError } from 'n8n-workflow';
import {
ErrorReporterProxy as ErrorReporter,
FORM_TRIGGER_PATH_IDENTIFIER,
NodeApiError,
} from 'n8n-workflow';
import { Readable } from 'node:stream';
import type {
IExecutionDb,
@@ -67,6 +71,20 @@ export function sendErrorResponse(res: Response, error: Error) {
console.error(picocolors.red(error.httpStatusCode), error.message);
}
//render custom 404 page for form triggers
const { originalUrl } = res.req;
if (error.errorCode === 404 && originalUrl) {
const basePath = originalUrl.split('/')[1];
const isLegacyFormTrigger = originalUrl.includes(FORM_TRIGGER_PATH_IDENTIFIER);
const isFormTrigger = basePath.includes('form');
if (isFormTrigger || isLegacyFormTrigger) {
const isTestWebhook = basePath.includes('test');
res.status(404);
return res.render('form-trigger-404', { isTestWebhook });
}
}
httpStatusCode = error.httpStatusCode;
if (error.errorCode) {