mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
⚡ Make it possible to set tunnel subdomain via environment variable
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import * as localtunnel from 'localtunnel';
|
||||
import {
|
||||
TUNNEL_SUBDOMAIN_ENV,
|
||||
UserSettings,
|
||||
} from "n8n-core";
|
||||
import { Command, flags } from '@oclif/command';
|
||||
@@ -14,8 +15,8 @@ import {
|
||||
GenericHelpers,
|
||||
LoadNodesAndCredentials,
|
||||
NodeTypes,
|
||||
TestWebhooks,
|
||||
Server,
|
||||
TestWebhooks,
|
||||
} from "../src";
|
||||
|
||||
const tunnel = promisify(localtunnel);
|
||||
@@ -120,7 +121,14 @@ export class Start extends Command {
|
||||
if (flags.tunnel === true) {
|
||||
this.log('\nWaiting for tunnel ...');
|
||||
|
||||
if (userSettings.tunnelSubdomain === undefined) {
|
||||
let tunnelSubdomain;
|
||||
if (process.env[TUNNEL_SUBDOMAIN_ENV] !== undefined && process.env[TUNNEL_SUBDOMAIN_ENV] !== '') {
|
||||
tunnelSubdomain = process.env[TUNNEL_SUBDOMAIN_ENV];
|
||||
} else if (userSettings.tunnelSubdomain !== undefined) {
|
||||
tunnelSubdomain = userSettings.tunnelSubdomain;
|
||||
}
|
||||
|
||||
if (tunnelSubdomain === undefined) {
|
||||
// When no tunnel subdomain did exist yet create a new random one
|
||||
const availableCharacters = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||
userSettings.tunnelSubdomain = Array.from({ length: 24 }).map(() => {
|
||||
@@ -132,7 +140,7 @@ export class Start extends Command {
|
||||
|
||||
const tunnelSettings: localtunnel.TunnelConfig = {
|
||||
host: 'https://hooks.n8n.cloud',
|
||||
subdomain: userSettings.tunnelSubdomain,
|
||||
subdomain: tunnelSubdomain,
|
||||
};
|
||||
|
||||
const port = config.get('port') as number;
|
||||
|
||||
Reference in New Issue
Block a user