Fix ROUTER_BASE_PATH override for empty string

When the `ROUTER_BASE_PATH` env variable is set to an empty string it's mistakenly overriden to `/audiobookshelf` instead.
The `/audiobookshelf` fallback should only be used when the `ROUTER_BASE_PATH` env variable is undefined, not just an empty string.

Regression introduced in https://github.com/advplyr/audiobookshelf/pull/3810
See also: https://github.com/advplyr/audiobookshelf/pull/3810#discussion_r1948790937

Partially address https://github.com/advplyr/audiobookshelf/issues/3874
This commit is contained in:
Paul 2025-02-10 11:41:26 +01:00
parent 0ccb88904a
commit 14e92435ec
No known key found for this signature in database
GPG key ID: 6A5AE3C3DF890E0F
3 changed files with 4 additions and 4 deletions

View file

@ -1,6 +1,6 @@
const pkg = require('./package.json')
const routerBasePath = process.env.ROUTER_BASE_PATH || '/audiobookshelf'
const routerBasePath = process.env.ROUTER_BASE_PATH ?? '/audiobookshelf'
const serverHostUrl = process.env.NODE_ENV === 'production' ? '' : 'http://localhost:3333'
const serverPaths = ['api/', 'public/', 'hls/', 'auth/', 'feed/', 'status', 'login', 'logout', 'init']
const proxy = Object.fromEntries(serverPaths.map((path) => [`${routerBasePath}/${path}`, { target: process.env.NODE_ENV !== 'production' ? serverHostUrl : '/' }]))