From 4991ab7b91560f77ba739a8127675a2840c4695f Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 17 Oct 2020 19:54:02 +0200 Subject: [PATCH] Fix local path when serving files --- main.js | 3 ++- package.json | 1 + yarn.lock | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 6a94ffe..b961153 100644 --- a/main.js +++ b/main.js @@ -1,4 +1,5 @@ const {app, BrowserWindow, shell} = require('electron') +const path = require('path') const express = require('express') const eApp = express() @@ -24,7 +25,7 @@ function createWindow() { mainWindow.setMenuBarVisibility(false) // Start a local express server to serve static files - eApp.use(express.static(frontendPath)) + eApp.use(express.static(path.join(__dirname, frontendPath))) // Handle urls set by the frontend eApp.get('*', (request, response, next) => { response.sendFile(`${__dirname}/${frontendPath}index.html`); diff --git a/package.json b/package.json index f5a7191..5d9dc33 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "electron-builder": "^22.9.1" }, "dependencies": { + "connect-history-api-fallback": "^1.6.0", "express": "^4.17.1" } } diff --git a/yarn.lock b/yarn.lock index 5e758b4..bc83192 100644 --- a/yarn.lock +++ b/yarn.lock @@ -433,6 +433,11 @@ configstore@^5.0.1: write-file-atomic "^3.0.0" xdg-basedir "^4.0.0" +connect-history-api-fallback@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz#8b32089359308d111115d81cad3fceab888f97bc" + integrity sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg== + content-disposition@0.5.3: version "0.5.3" resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.3.tgz#e130caf7e7279087c5616c2007d0485698984fbd"