From b89ff796bf0f2c1ea957879b1a5055465b1f4246 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Wed, 15 Apr 2026 18:38:13 -0700 Subject: [PATCH] Fix OAuth callback port hardcoding and add diagnostic logging Auth instruction pages and log messages now use the actual configured callback port instead of hardcoding 8888. Added startup logging that prints whether SOULSYNC_SPOTIFY/TIDAL_CALLBACK_PORT env vars were detected, helping diagnose Unraid/Docker env var issues. Also fixes uses_main_port detection for custom callback ports and moves the wishlist button handler to global init so it works on all pages. --- docker-compose.yml | 2 +- web_server.py | 35 ++++++++++++++++++++++++++--------- webui/static/helper.js | 2 ++ webui/static/script.js | 12 ++++++------ 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index a757456b..b8e4dfc4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,7 +22,7 @@ services: - TZ=America/New_York # OAuth callback ports. If 8888/8889 conflict with another container (e.g. Gluetun), # change the port numbers below AND update the matching port mappings in the ports section. - # Then update the redirect URI in SoulSync → Settings → Connections to match. + # Then update the redirect URI in SoulSync → Settings → Connections AND in your Spotify/Tidal developer dashboard to match. - SOULSYNC_SPOTIFY_CALLBACK_PORT=8888 - SOULSYNC_TIDAL_CALLBACK_PORT=8889 ports: diff --git a/web_server.py b/web_server.py index e4532e0d..f0858cde 100644 --- a/web_server.py +++ b/web_server.py @@ -6950,8 +6950,12 @@ def auth_spotify(): if is_docker and host == '127.0.0.1': host = 'localhost' - # Check if the redirect_uri uses port 8008 (main app) vs 8888 (standalone) - uses_main_port = ':8008' in configured_uri or ':8888' not in configured_uri + # Check if the redirect_uri uses port 8008 (main app) vs the standalone callback server. + # A localhost URI (127.0.0.1/localhost) on a non-8008 port → standalone callback server. + # A custom domain or port 8008 → main Flask app (or reverse proxy to it). + uses_main_port = ':8008' in configured_uri or ( + '127.0.0.1' not in configured_uri and 'localhost' not in configured_uri + ) if is_remote or is_docker: # Show instructions for remote/docker access @@ -6980,7 +6984,10 @@ def auth_spotify(): ''' else: - # redirect_uri still points to port 8888 — show manual steps AND suggest switching + # redirect_uri points to the standalone callback server — show manual steps AND suggest switching + import re as _re + _port_match = _re.search(r':(\d+)/', configured_uri) + callback_server_port = _port_match.group(1) if _port_match else str(os.environ.get('SOULSYNC_SPOTIFY_CALLBACK_PORT', '8888')) return f''' @@ -7008,7 +7015,7 @@ def auth_spotify():
Using a reverse proxy? Your redirect URI is set to {configured_uri} - which uses port 8888. If you're behind a reverse proxy (Caddy, Nginx, Traefik), change the + which uses port {callback_server_port}. If you're behind a reverse proxy (Caddy, Nginx, Traefik), change the redirect URI in SoulSync settings to use your proxy URL on the main port instead, e.g.:
https://{host}/callback
Then update the same URI in your Spotify Dashboard. @@ -7019,11 +7026,11 @@ def auth_spotify():

{auth_url}


Step 2: After authorizing, you'll see a blank page. The URL will look like:

- http://127.0.0.1:8888/callback?code=... + http://127.0.0.1:{callback_server_port}/callback?code=...

Step 3: Change 127.0.0.1 to {host} and press Enter:

- http://{host}:8888/callback?code=... + http://{host}:{callback_server_port}/callback?code=...

Authentication will then complete!