File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,14 +75,17 @@ async function generateCodeChallenge(verifier: string): Promise<string> {
7575}
7676
7777function getRedirectUri ( ) : string {
78+ // Spotify requires http://127.0.0.1 for loopback redirects (rejects http://localhost)
79+ // Always use 127.0.0.1 with the current port for Tauri/local builds
7880 const origin = window . location . origin
79- // In production Tauri, app is served via localhost plugin on http://localhost:3080
80- // Use the actual origin so the redirect URI matches what Spotify redirects back to
81- if ( origin . startsWith ( 'tauri://' ) ) {
82- // Fallback if localhost plugin isn't active (shouldn't happen)
83- return 'http://localhost:3080/'
81+ if (
82+ origin . startsWith ( 'tauri://' ) ||
83+ origin . includes ( 'localhost' ) ||
84+ origin . includes ( '127.0.0.1' )
85+ ) {
86+ const port = window . location . port || '3080'
87+ return `http://127.0.0.1:${ port } /`
8488 }
85- // Use origin directly — works for localhost:3080 (Tauri prod), localhost:3000 (dev), or deployed URL
8689 return origin + '/'
8790}
8891
You can’t perform that action at this time.
0 commit comments