fix(desktop): use app.use to serve frontend files

This fix avoids route patterns and instead uses a middleware to serve frontend files in express. The route pattern was causing errors in the path-to-regexp package used by express.

Resolves https://github.com/go-vikunja/vikunja/issues/687
Resolves https://community.vikunja.io/t/the-state-of-the-windows-desktop-app/3618/4
This commit is contained in:
kolaente
2025-05-20 15:48:02 +02:00
parent 1648b71634
commit dc20d55be6

View File

@@ -35,9 +35,9 @@ function createWindow() {
// Start a local express server to serve static files
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`);
// Handle urls set by the frontend - use app.use as catch-all instead of route pattern
eApp.use((request, response) => {
response.sendFile(path.join(__dirname, frontendPath, 'index.html'))
})
const server = eApp.listen(port, '127.0.0.1', () => {
console.log(`Server started on port ${server.address().port}`)