Yooooomi / your_spotify

Self hosted Spotify tracking dashboard
GNU General Public License v3.0
3.12k stars 125 forks source link

Illegal Redirect URI #175

Closed jeusch8 closed 4 months ago

jeusch8 commented 1 year ago

Describe the bug

When trying to sign in to your spotify when reversed proxied, an Illegal redirect uri occurs. Does not occur when using local ips. The first link works, but when I go to hit sign in thats when the redirect fails.

Expected behavior

Page loads into sign in to allow users to sign into the app.

Additional context Browser is Firefox, OS Win10

Docker Compose Excerpt

services: server: image: yooooomi/your_spotify_server container_name: spotifyserver ports:

SWAG Configs (sorry these arent wrapping correctly) ` server { listen 443 ssl; listen [::]:443 ssl;

server_name spotifystats.*;

include /config/nginx/ssl.conf;

client_max_body_size 0;

# enable for ldap auth (requires ldap-location.conf in the location block)
#include /config/nginx/ldap-server.conf;

# enable for Authelia (requires authelia-location.conf in the location block)
#include /config/nginx/authelia-server.conf;

location / {
    # enable the next two lines for http auth
    #auth_basic "Restricted";
    #auth_basic_user_file /config/nginx/.htpasswd;

    # enable for ldap auth (requires ldap-server.conf in the server block)
    #include /config/nginx/ldap-location.conf;

    # enable for Authelia (requires authelia-server.conf in the server block)
    #include /config/nginx/authelia-location.conf;

    include /config/nginx/proxy.conf;
    include /config/nginx/resolver.conf;
    set $upstream_app spotifystats;
    set $upstream_port 3000;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    # REMOVE THIS LINE BEFORE SUBMITTING: Additional proxy settings such as headers go below this line, leave the blank line above.
}

# location ~ (/<container_name>)?/api {
#     include /config/nginx/proxy.conf;
#     include /config/nginx/resolver.conf;
#     set $upstream_app <container_name>;
#     set $upstream_port <port_number>;
#     set $upstream_proto <http or https>;
#     proxy_pass $upstream_proto://$upstream_app:$upstream_port;
#
#    
# }

} `

`server { listen 443 ssl; listen [::]:443 ssl;

server_name spotifyserver.*;

include /config/nginx/ssl.conf;

client_max_body_size 0;

# enable for ldap auth (requires ldap-location.conf in the location block)
#include /config/nginx/ldap-server.conf;

# enable for Authelia (requires authelia-location.conf in the location block)
#include /config/nginx/authelia-server.conf;

location / {
    # enable the next two lines for http auth
    #auth_basic "Restricted";
    #auth_basic_user_file /config/nginx/.htpasswd;

    # enable for ldap auth (requires ldap-server.conf in the server block)
    #include /config/nginx/ldap-location.conf;

    # enable for Authelia (requires authelia-server.conf in the server block)
    #include /config/nginx/authelia-location.conf;

    include /config/nginx/proxy.conf;
    include /config/nginx/resolver.conf;
    set $upstream_app spotifyserver;
    set $upstream_port 8080;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

}

# location ~ (/<container_name>)?/api {
#     include /config/nginx/proxy.conf;
#     include /config/nginx/resolver.conf;
#     set $upstream_app <container_name>;
#     set $upstream_port <port_number>;
#     set $upstream_proto <http or https>;
#     proxy_pass $upstream_proto://$upstream_app:$upstream_port;
#
#     
# }

} ` Screenshots

If applicable, add screenshots to help explain your problem.

spotify2 spot4 Domain = whatever your domain, was changed for privacy

Yooooomi commented 1 year ago

Hello! Could you try only setting one redirect uri? The redirect uri being the endpoint of your backend followed by the suffix you set.

jeusch8 commented 1 year ago

Hello, thank you for such a prompt response. Set it to just the one and still getting the error. I did hit save just to cover all your bases.

Yooooomi commented 1 year ago

I'm also curious why your swagger configuration seems to target the container port directly and you still expose them in the docker-compose.

jeusch8 commented 1 year ago

Good point, I had those for the local IP and just never changed them, I commented them out and removed the containers and then redeployed them. That doesnt seem to have changed anything either. Still getting that illegal redirect uri. What is confusing is that the server is reachable thru the reverse proxy, and so is the client thru spotifystats subdomain, Im just confused why when it breaks when i use my reverse proxy vs when i just use it locally over my desktop ip and the headless server ip

services: server: image: yooooomi/your_spotify_server container_name: spotifyserver links:

Yooooomi commented 1 year ago

It's actually weird, I don't see anything wrong with your configuration. Could you please try deleting and recreating your app? Also please be sure to hit the save button at the bottom of the popup when adding the callbacks for the first time.

jeusch8 commented 1 year ago

I just nuked the entire setup, deleted the images, deleted the app, everything and rebuilt it with the new id and secret, hit yes and all that, and its still not working for some reason. Even changed some of the spaces to make sure that the space was messing things up and its still not working. Im very confused honestly. I literally had it working locally, but the second its reverse proxied with swag it doesnt work?

services: server: image: yooooomi/your_spotify_server container_name: spotifyserver links:

jeusch8 commented 1 year ago

Oh? It just started working after I removed it and added it a bunch of times. Ill do a bit more investigating why it just started working.

Yooooomi commented 1 year ago

Yes it can be capricious sometimes. Feel free to close if it disappeared forever :)

jeusch8 commented 1 year ago

For anyone that looks at this issue, I have no idea what fixed it, I changed the redirect uri between /oauth/spotify/callback to /oauth/spotify/callback/ and then back again to /oauth/spotify/callback and that somehow fixed it after deleting the spotify app itself, deleted the docker containers, deleted all images related to this project, deleted the mongo db files itself in the console, and recreated everything. I assume it was something to do with how it was used locally then reversed proxied. Hopefully this helps. Removed some domain names to stay private.

jeusch8 commented 4 months ago

Hello,

Recently Ive had to rebuild this and it broke again. Ive tried so many different combinations of what I posted before, Im genuinely at a loss.

Your Spotify API

server: image: yooooomi/your_spotify_server container_name: your-spotify-server links:

These are my swag proxies, completely unchanged. https://github.com/linuxserver/reverse-proxy-confs/blob/master/your-spotify-api.subdomain.conf.sample https://github.com/linuxserver/reverse-proxy-confs/blob/master/your-spotify.subdomain.conf.sample

jeusch8 commented 4 months ago

Seems to be a cache issue on browser, clearing cache seems to have fixed the problem, the one thing I did not do. Apologies for the bump.