[GH-ISSUE #317] [Feature]: Spotify DJ login when Marinara is accessed from another device #133

Closed
opened 2026-10-20 17:25:30 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @LightD31 on GitHub (Apr 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/317

What problem does this solve?

The Spotify DJ agent's OAuth callback is hardcoded to http://127.0.0.1:<PORT>/api/spotify/callback. When Marinara runs on a different machine than the browser (LAN install, remote server, Tailscale, phone-on-Wi-Fi, etc.), Spotify redirects the popup to 127.0.0.1 on the browser's machine — where nothing is listening — so the connect flow silently times out after 5 minutes.

Naively swapping in the LAN IP doesn't fix it: Spotify tightened redirect-URI rules in Feb 2025 so registered URIs must be https://<any-host> or the loopback literals http://127.0.0.1 / http://[::1]. localhost and LAN IPs (e.g. http://192.168.1.42:7860) are rejected at registration time.

Proposed solution

Three-pronged so every reasonable deployment shape works:

  1. Auto-derive the redirect URI from the incoming request — https://<host>/api/spotify/callback when the request is HTTPS (own TLS or X-Forwarded-Proto: https); keep http://127.0.0.1:<PORT>/... for localhost; fall back to the same loopback URI for plain-HTTP non-loopback (since Spotify rejects everything else).
  2. Add a SPOTIFY_REDIRECT_URI env override for HTTPS-terminated-upstream setups where the request host doesn't match the public URL.
  3. Add a manual paste-back path in the agent editor for plain-HTTP LAN installs: user copies the failed-popup URL from their address bar and pastes it into a small disclosure under the Connect button; server extracts code+state from the URL and completes the token exchange against the existing PKCE pending-auth entry.

Alternatives considered

  • Force HTTPS for all non-localhost setups. Cleanest from Spotify's perspective but a real burden for casual LAN users (self-signed cert + browser warnings, or a reverse proxy). Worth recommending in docs but not a hard requirement.

Additional context

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @LightD31 on GitHub (Apr 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/317 ## What problem does this solve? The Spotify DJ agent's OAuth callback is hardcoded to `http://127.0.0.1:<PORT>/api/spotify/callback`. When Marinara runs on a different machine than the browser (LAN install, remote server, Tailscale, phone-on-Wi-Fi, etc.), Spotify redirects the popup to `127.0.0.1` on the *browser's* machine — where nothing is listening — so the connect flow silently times out after 5 minutes. Naively swapping in the LAN IP doesn't fix it: Spotify [tightened redirect-URI rules in Feb 2025](https://developer.spotify.com/blog/2025-02-12-increasing-the-security-requirements-for-integrating-with-spotify) so registered URIs must be `https://<any-host>` or the loopback literals `http://127.0.0.1` / `http://[::1]`. `localhost` and LAN IPs (e.g. `http://192.168.1.42:7860`) are rejected at registration time. ## Proposed solution Three-pronged so every reasonable deployment shape works: 1. **Auto-derive the redirect URI from the incoming request** — `https://<host>/api/spotify/callback` when the request is HTTPS (own TLS or `X-Forwarded-Proto: https`); keep `http://127.0.0.1:<PORT>/...` for localhost; fall back to the same loopback URI for plain-HTTP non-loopback (since Spotify rejects everything else). 2. **Add a `SPOTIFY_REDIRECT_URI` env override** for HTTPS-terminated-upstream setups where the request host doesn't match the public URL. 3. **Add a manual paste-back path in the agent editor** for plain-HTTP LAN installs: user copies the failed-popup URL from their address bar and pastes it into a small disclosure under the Connect button; server extracts `code`+`state` from the URL and completes the token exchange against the existing PKCE pending-auth entry. ## Alternatives considered - **Force HTTPS for all non-localhost setups.** Cleanest from Spotify's perspective but a real burden for casual LAN users (self-signed cert + browser warnings, or a reverse proxy). Worth recommending in docs but not a hard requirement. ## Additional context - Reproduction: run with `HOST=0.0.0.0` on machine A, open `http://<machine-A-IP>:7860` from machine B, try to connect Spotify → popup loads `http://127.0.0.1:7860/api/spotify/callback` on machine B and fails. - Hardcoded callback location: [`packages/server/src/config/runtime-config.ts`](https://github.com/Pasta-Devs/Marinara-Engine/blob/main/packages/server/src/config/runtime-config.ts) — `getSpotifyRedirectUri()`. - Related Spotify policy post: https://developer.spotify.com/blog/2025-02-12-increasing-the-security-requirements-for-integrating-with-spotify ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:25:30 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#133
No description provided.