Skip to content

Commit

Permalink
fix(core): fix hooks URLs no longer added to index.html (n8n-io#4262)
Browse files Browse the repository at this point in the history
🐛 Fix hooks URLs no longer added to `index.html`
  • Loading branch information
ivov authored Oct 4, 2022
1 parent bdd8629 commit a139078
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1789,16 +1789,16 @@ class App {
const editorUiDistDir = pathJoin(pathDirname(require.resolve('n8n-editor-ui')), 'dist');
const generatedStaticDir = pathJoin(__dirname, '../public');

const firstLinkedScriptSegment = '<link href="/js/';
const closingTitleTag = '</title>';
const compileFile = async (fileName: string) => {
const filePath = pathJoin(editorUiDistDir, fileName);
if (/(index.html)|.*\.(js|css)/.test(filePath) && existsSync(filePath)) {
if (/(index\.html)|.*\.(js|css)/.test(filePath) && existsSync(filePath)) {
const srcFile = await readFile(filePath, 'utf8');
let payload = srcFile.replace(basePathRegEx, n8nPath);
if (filePath === 'index.html') {
if (filePath.endsWith('index.html')) {
payload = payload
.replace(/\/favicon.ico/g, `${n8nPath}favicon.ico`)
.replace(firstLinkedScriptSegment, scriptsString + firstLinkedScriptSegment);
.replace(/\/favicon\.ico/g, `${n8nPath}favicon.ico`)
.replace(closingTitleTag, closingTitleTag + scriptsString);
}
const destFile = pathJoin(generatedStaticDir, fileName);
await mkdir(pathDirname(destFile), { recursive: true });
Expand Down

0 comments on commit a139078

Please sign in to comment.