This pull request introduces several improvements focused on robust URL resolution for the Listenarr API, especially in Docker and reverse proxy environments, and adds diagnostics for bot startup issues. The most important changes include enhanced logic for determining the public Listenarr URL, Docker-aware fallbacks, increased logging for troubleshooting, and a new diagnostics endpoint for the Discord bot.
URL Resolution and Docker Compatibility:
- Added a new
GetListenarrUrl()method inDiscordBotServicethat prioritizes URL sources as follows: environment variable (LISTENARR_PUBLIC_URL), current HTTP request (usingIHttpContextAccessorand honoringX-Forwarded-*headers), startup config, and finally a Docker-aware fallback (host.docker.internalifDOCKER_ENVis set, otherwiselocalhost). This makes the bot's connection to the API more reliable in varied deployment scenarios. - Injected
IHttpContextAccessorintoDiscordBotServiceto allow constructing the public URL from the current HTTP request, improving compatibility with reverse proxies. - Updated the Dockerfile (
listenarr.api/Dockerfile.runtime) to setDOCKER_ENV=trueby default, enabling Docker-aware fallbacks for local host resolution.
Logging and Diagnostics:
- Added detailed per-step logging in
DiscordBotServiceto indicate which source was used for URL resolution and to log header-based values, aiding troubleshooting of connectivity issues. - Introduced a new
/diagnosticsendpoint inDiscordControllerthat checks for the existence of the bot directory,index.js, and the availability of Node.js, making it easier to debug bot startup issues in production.
Documentation and Recommendations:
- Updated the
CHANGELOG.mdto document these changes, including recommendations to setLISTENARR_PUBLIC_URLin production and to use the new Docker environment variable for improved reliability.
These changes collectively make Listenarr more ...
Automated canary build