@@ -147,6 +147,7 @@ import {
147
147
WebhookServer ,
148
148
WorkflowExecuteAdditionalData ,
149
149
} from '.' ;
150
+ import glob from 'fast-glob' ;
150
151
import { ResponseError } from './ResponseHelper' ;
151
152
152
153
require ( 'body-parser-xml' ) ( bodyParser ) ;
@@ -389,6 +390,7 @@ class App {
389
390
const excludeEndpoints = config . getEnv ( 'security.excludeEndpoints' ) ;
390
391
391
392
const ignoredEndpoints = [
393
+ 'assets' ,
392
394
'healthz' ,
393
395
'metrics' ,
394
396
this . endpointWebhook ,
@@ -1753,11 +1755,28 @@ class App {
1753
1755
const editorUiPath = require . resolve ( 'n8n-editor-ui' ) ;
1754
1756
const filePath = pathJoin ( pathDirname ( editorUiPath ) , 'dist' , 'index.html' ) ;
1755
1757
const n8nPath = config . getEnv ( 'path' ) ;
1758
+ const basePathRegEx = / \/ % B A S E _ P A T H % \/ / g;
1756
1759
1757
1760
let readIndexFile = readFileSync ( filePath , 'utf8' ) ;
1758
- readIndexFile = readIndexFile . replace ( / \/ % B A S E _ P A T H % \/ / g , n8nPath ) ;
1761
+ readIndexFile = readIndexFile . replace ( basePathRegEx , n8nPath ) ;
1759
1762
readIndexFile = readIndexFile . replace ( / \/ f a v i c o n .i c o / g, `${ n8nPath } favicon.ico` ) ;
1760
1763
1764
+ const cssPath = pathJoin ( pathDirname ( editorUiPath ) , 'dist' , '**/*.css' ) ;
1765
+ const cssFiles : Record < string , string > = { } ;
1766
+ glob . sync ( cssPath ) . forEach ( ( filePath ) => {
1767
+ let readFile = readFileSync ( filePath , 'utf8' ) ;
1768
+ readFile = readFile . replace ( basePathRegEx , n8nPath ) ;
1769
+ cssFiles [ filePath . replace ( pathJoin ( pathDirname ( editorUiPath ) , 'dist' ) , '' ) ] = readFile ;
1770
+ } ) ;
1771
+
1772
+ const jsPath = pathJoin ( pathDirname ( editorUiPath ) , 'dist' , '**/*.js' ) ;
1773
+ const jsFiles : Record < string , string > = { } ;
1774
+ glob . sync ( jsPath ) . forEach ( ( filePath ) => {
1775
+ let readFile = readFileSync ( filePath , 'utf8' ) ;
1776
+ readFile = readFile . replace ( basePathRegEx , n8nPath ) ;
1777
+ jsFiles [ filePath . replace ( pathJoin ( pathDirname ( editorUiPath ) , 'dist' ) , '' ) ] = readFile ;
1778
+ } ) ;
1779
+
1761
1780
const hooksUrls = config . getEnv ( 'externalFrontendHooksUrls' ) ;
1762
1781
1763
1782
let scriptsString = '' ;
@@ -1793,6 +1812,14 @@ class App {
1793
1812
res . send ( readIndexFile ) ;
1794
1813
} ) ;
1795
1814
1815
+ this . app . get ( '/assets/*.css' , async ( req : express . Request , res : express . Response ) => {
1816
+ res . type ( 'text/css' ) . send ( cssFiles [ req . url ] ) ;
1817
+ } ) ;
1818
+
1819
+ this . app . get ( '/assets/*.js' , async ( req : express . Request , res : express . Response ) => {
1820
+ res . type ( 'text/javascript' ) . send ( jsFiles [ req . url ] ) ;
1821
+ } ) ;
1822
+
1796
1823
// Serve the website
1797
1824
this . app . use (
1798
1825
'/' ,
0 commit comments