mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
✨ Make it possible to disable the UI
This commit is contained in:
parent
1e42effc3a
commit
48f0f71f95
|
@ -507,6 +507,12 @@ const config = convict({
|
||||||
env: 'N8N_ENDPOINT_WEBHOOK_TEST',
|
env: 'N8N_ENDPOINT_WEBHOOK_TEST',
|
||||||
doc: 'Path for test-webhook endpoint',
|
doc: 'Path for test-webhook endpoint',
|
||||||
},
|
},
|
||||||
|
disableUi: {
|
||||||
|
format: Boolean,
|
||||||
|
default: false,
|
||||||
|
env: 'N8N_DISABLE_UI',
|
||||||
|
doc: 'Disable N8N UI (Frontend).',
|
||||||
|
},
|
||||||
disableProductionWebhooksOnMainProcess: {
|
disableProductionWebhooksOnMainProcess: {
|
||||||
format: Boolean,
|
format: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
|
|
@ -2884,36 +2884,38 @@ class App {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the index file and replace the path placeholder
|
if (config.get('endpoints.disableUi') !== true) {
|
||||||
const editorUiPath = require.resolve('n8n-editor-ui');
|
// Read the index file and replace the path placeholder
|
||||||
const filePath = pathJoin(pathDirname(editorUiPath), 'dist', 'index.html');
|
const editorUiPath = require.resolve('n8n-editor-ui');
|
||||||
const n8nPath = config.get('path');
|
const filePath = pathJoin(pathDirname(editorUiPath), 'dist', 'index.html');
|
||||||
|
const n8nPath = config.get('path');
|
||||||
|
|
||||||
let readIndexFile = readFileSync(filePath, 'utf8');
|
let readIndexFile = readFileSync(filePath, 'utf8');
|
||||||
readIndexFile = readIndexFile.replace(/\/%BASE_PATH%\//g, n8nPath);
|
readIndexFile = readIndexFile.replace(/\/%BASE_PATH%\//g, n8nPath);
|
||||||
readIndexFile = readIndexFile.replace(/\/favicon.ico/g, `${n8nPath}favicon.ico`);
|
readIndexFile = readIndexFile.replace(/\/favicon.ico/g, `${n8nPath}favicon.ico`);
|
||||||
|
|
||||||
// Serve the altered index.html file separately
|
// Serve the altered index.html file separately
|
||||||
this.app.get(`/index.html`, async (req: express.Request, res: express.Response) => {
|
this.app.get(`/index.html`, async (req: express.Request, res: express.Response) => {
|
||||||
res.send(readIndexFile);
|
res.send(readIndexFile);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serve the website
|
// Serve the website
|
||||||
|
this.app.use(
|
||||||
|
'/',
|
||||||
|
express.static(pathJoin(pathDirname(editorUiPath), 'dist'), {
|
||||||
|
index: 'index.html',
|
||||||
|
setHeaders: (res, path) => {
|
||||||
|
if (res.req && res.req.url === '/index.html') {
|
||||||
|
// Set last modified date manually to n8n start time so
|
||||||
|
// that it hopefully refreshes the page when a new version
|
||||||
|
// got used
|
||||||
|
res.setHeader('Last-Modified', startTime);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
const startTime = new Date().toUTCString();
|
const startTime = new Date().toUTCString();
|
||||||
this.app.use(
|
|
||||||
'/',
|
|
||||||
express.static(pathJoin(pathDirname(editorUiPath), 'dist'), {
|
|
||||||
index: 'index.html',
|
|
||||||
setHeaders: (res, path) => {
|
|
||||||
if (res.req && res.req.url === '/index.html') {
|
|
||||||
// Set last modified date manually to n8n start time so
|
|
||||||
// that it hopefully refreshes the page when a new version
|
|
||||||
// got used
|
|
||||||
res.setHeader('Last-Modified', startTime);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue