Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/cli/src/services/__tests__/frontend.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,12 @@ describe('FrontendService', () => {
process.env.N8N_PREVIEW_MODE = 'true';

const { service } = createMockService();
const settings = await service.getPublicSettings(false);
const publicSettings = await service.getPublicSettings(false);

expect(publicSettings.previewMode).toBe(true);
expect(publicSettings.userManagement.showSetupOnFirstLoad).toBe(false);

const settings = await service.getSettings();
expect(settings.previewMode).toBe(true);
expect(settings.userManagement.showSetupOnFirstLoad).toBe(false);
});
Expand Down
19 changes: 13 additions & 6 deletions packages/cli/src/services/frontend.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ export class FrontendService {
return envFeatureFlags;
}

private async getShowSetupOnFirstLoad() {
const previewMode = process.env.N8N_PREVIEW_MODE === 'true';
const hasInstanceOwner = await this.ownershipService.hasInstanceOwner();
// In preview mode, skip the setup redirect to allow accessing demo routes
return previewMode ? false : !hasInstanceOwner;
}

private async initSettings() {
const instanceBaseUrl = this.urlService.getInstanceBaseUrl();
const restEndpoint = this.globalConfig.endpoints.rest;
Expand All @@ -172,12 +179,14 @@ export class FrontendService {
telemetrySettings.config = { key, url, proxy, sourceConfig };
}

const previewMode = process.env.N8N_PREVIEW_MODE === 'true';

this.settings = {
settingsMode: 'authenticated',
inE2ETests,
isDocker: this.instanceSettings.isDocker,
databaseType: this.globalConfig.database.type,
previewMode: process.env.N8N_PREVIEW_MODE === 'true',
previewMode,
endpointForm: this.globalConfig.endpoints.form,
endpointFormTest: this.globalConfig.endpoints.formTest,
endpointFormWaiting: this.globalConfig.endpoints.formWaiting,
Expand Down Expand Up @@ -237,7 +246,7 @@ export class FrontendService {
defaultLocale: this.globalConfig.defaultLocale,
userManagement: {
quota: this.license.getUsersLimit(),
showSetupOnFirstLoad: !(await this.ownershipService.hasInstanceOwner()),
showSetupOnFirstLoad: await this.getShowSetupOnFirstLoad(),
smtpSetup: this.mailer.isEmailSetUp,
authenticationMethod: getCurrentAuthenticationMethod(),
},
Expand Down Expand Up @@ -408,7 +417,7 @@ export class FrontendService {
Object.assign(this.settings.userManagement, {
quota: this.license.getUsersLimit(),
authenticationMethod: getCurrentAuthenticationMethod(),
showSetupOnFirstLoad: !(await this.ownershipService.hasInstanceOwner()),
showSetupOnFirstLoad: await this.getShowSetupOnFirstLoad(),
});

let dismissedBanners: string[] = [];
Expand Down Expand Up @@ -555,14 +564,12 @@ export class FrontendService {
mfa,
communityNodesEnabled,
} = await this.getSettings();

const publicSettings: PublicFrontendSettings = {
settingsMode: 'public',
defaultLocale,
userManagement: {
authenticationMethod,
// In preview mode, skip the setup redirect to allow accessing demo routes
showSetupOnFirstLoad: previewMode ? false : showSetupOnFirstLoad,
showSetupOnFirstLoad,
smtpSetup,
},
sso: {
Expand Down