fix(core): App should not crash with a custom rest endpoint (#5911)
fixes #5880
This commit is contained in:
committed by
GitHub
parent
6689451e8c
commit
2881ee9ecc
@@ -10,7 +10,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
|
||||
import assert from 'assert';
|
||||
import { exec as callbackExec } from 'child_process';
|
||||
import { access as fsAccess } from 'fs/promises';
|
||||
import os from 'os';
|
||||
@@ -452,6 +452,11 @@ class Server extends AbstractServer {
|
||||
...excludeEndpoints.split(':'),
|
||||
].filter((u) => !!u);
|
||||
|
||||
assert(
|
||||
!ignoredEndpoints.includes(this.restEndpoint),
|
||||
`REST endpoint cannot be set to any of these values: ${ignoredEndpoints.join()} `,
|
||||
);
|
||||
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
const authIgnoreRegex = new RegExp(`^\/(${ignoredEndpoints.join('|')})\/?.*$`);
|
||||
|
||||
|
||||
@@ -144,6 +144,7 @@ export class Start extends BaseCommand {
|
||||
private async generateStaticAssets() {
|
||||
// Read the index file and replace the path placeholder
|
||||
const n8nPath = config.getEnv('path');
|
||||
const restEndpoint = config.getEnv('endpoints.rest');
|
||||
const hooksUrls = config.getEnv('externalFrontendHooksUrls');
|
||||
|
||||
let scriptsString = '';
|
||||
@@ -167,6 +168,7 @@ export class Start extends BaseCommand {
|
||||
];
|
||||
if (filePath.endsWith('index.html')) {
|
||||
streams.push(
|
||||
replaceStream('{{REST_ENDPOINT}}', restEndpoint, { ignoreCase: false }),
|
||||
replaceStream(closingTitleTag, closingTitleTag + scriptsString, {
|
||||
ignoreCase: false,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user