mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor-ui): fix axios baseUrl when hosted under a subfolder (#4336)
* fix(editor-ui): fix axios baseUrl when hosted under a subfolder * don't rewrite the favicon url twice * setup a base href for all relative urls * fix static urls
This commit is contained in:
parent
6a37071350
commit
c2e9a03ac5
|
@ -1798,11 +1798,11 @@ class App {
|
||||||
const filePath = pathJoin(editorUiDistDir, fileName);
|
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');
|
const srcFile = await readFile(filePath, 'utf8');
|
||||||
let payload = srcFile.replace(basePathRegEx, n8nPath);
|
let payload = srcFile
|
||||||
|
.replace(basePathRegEx, n8nPath)
|
||||||
|
.replace(/\/static\//g, pathJoin(n8nPath, 'static/'));
|
||||||
if (filePath.endsWith('index.html')) {
|
if (filePath.endsWith('index.html')) {
|
||||||
payload = payload
|
payload = payload.replace(closingTitleTag, closingTitleTag + scriptsString);
|
||||||
.replace(/\/favicon\.ico/g, `${n8nPath}favicon.ico`)
|
|
||||||
.replace(closingTitleTag, closingTitleTag + scriptsString);
|
|
||||||
}
|
}
|
||||||
const destFile = pathJoin(generatedStaticDir, fileName);
|
const destFile = pathJoin(generatedStaticDir, fileName);
|
||||||
await mkdir(pathDirname(destFile), { recursive: true });
|
await mkdir(pathDirname(destFile), { recursive: true });
|
||||||
|
|
|
@ -56,7 +56,7 @@ function getTemplatesRedirect(store: Store<IRootState>) {
|
||||||
const router = new Router({
|
const router = new Router({
|
||||||
mode: 'history',
|
mode: 'history',
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
base: window.BASE_PATH === '/{{BASE_PATH}}/' ? '/' : window.BASE_PATH,
|
base: window.BASE_PATH ?? '/',
|
||||||
scrollBehavior(to, from, savedPosition) {
|
scrollBehavior(to, from, savedPosition) {
|
||||||
// saved position == null means the page is NOT visited from history (back button)
|
// saved position == null means the page is NOT visited from history (back button)
|
||||||
if (savedPosition === null && to.name === VIEWS.TEMPLATES && to.meta) {
|
if (savedPosition === null && to.name === VIEWS.TEMPLATES && to.meta) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ const state: IRootState = {
|
||||||
activeNode: null,
|
activeNode: null,
|
||||||
activeCredentialType: null,
|
activeCredentialType: null,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
baseUrl: import.meta.env.VUE_APP_URL_BASE_API ? import.meta.env.VUE_APP_URL_BASE_API : (window.BASE_PATH === '/{{BASE_PATH}}/' ? '/' : window.BASE_PATH),
|
baseUrl: import.meta.env.VUE_APP_URL_BASE_API ?? window.BASE_PATH ?? '/',
|
||||||
defaultLocale: 'en',
|
defaultLocale: 'en',
|
||||||
endpointWebhook: 'webhook',
|
endpointWebhook: 'webhook',
|
||||||
endpointWebhookTest: 'webhook-test',
|
endpointWebhookTest: 'webhook-test',
|
||||||
|
|
Loading…
Reference in a new issue