your_spotify icon indicating copy to clipboard operation
your_spotify copied to clipboard

Issue with Logging In

Open DarkKronicle opened this issue 2 years ago • 8 comments

Hello! I'm having some trouble getting logging in to work.

Here is my current docker compose setup for the project:

  spotify-server:
    image: yooooomi/your_spotify_server
    restart: always
    ports:
      - "8888:8080"
    links:
      - mongo
    depends_on:
      - mongo
    environment:
      - API_ENDPOINT=https://myspotify.DOMAIN.com/api
      - CLIENT_ENDPOINT=https://myspotify.DOMAIN.com
      - SPOTIFY_PUBLIC=XXXXXXXXXX
      - SPOTIFY_SECRET=XXXXXXXXXX
      - CORS=all # All for testing purposes
      
  mongo:
    container_name: mongo
    image: mongo:4.4.8
    volumes:
      - ./your_spotify_db:/data/db

  spotify-client:
    image: yooooomi/your_spotify_client
    restart: always
    ports:
      - "3333:3000"
    environment:
      - API_ENDPOINT=https://myspotify.DOMAIN.com/api

Connecting to both authmyspotify and myspotify works. When connecting to myspotify and I click Log In, it goes to https://myspotify.DOMAIN.com/oauth/spotify and shows a blank dashboard. If I change the URL to https://myspotify.DOMAIN.com/api/oauth/spotify I'm able to authorize, but it then redirects me back to https://myspotify.DOMAIN.com/login. Looking at the logs of the server, it looks like it correctly logs me in, it's just the front end that doesn't log in correctly.

Screenshot of after clicking log in: image

Thanks for the help!

DarkKronicle avatar Aug 02 '22 17:08 DarkKronicle

Ok, so I got it to work, though I am still very confused.

After messing with it for a while, I realized that API_ENDPOINT wasn't carried over in the front-end, even though in the console it said it was. I looked at environment variables, and it was all set, but the login button and other endpoints wouldn't go to the correct URL. Randomly after a reset (even though I did it many times) it fixed itself. I don't know if it was because a container was removed or something, or if something was cached weird. I changed it to myspotify.DOMAIN.com/api but then it went to authmyspotify.DOMAIN.com which was what was set before.

Works now, so I don't mind, but mainly just confused now lol.

DarkKronicle avatar Aug 02 '22 20:08 DarkKronicle

Hello, sorry for not reaching to you sooner. Is your issue resolved?

Yooooomi avatar Sep 03 '22 18:09 Yooooomi

Hello, sorry for not reaching to you sooner. Is your issue resolved?

I am having the exact same issue, any fix for this?

Dhruvgera avatar Sep 28 '22 14:09 Dhruvgera

@Dhruvgera hello. I can't help you without any configuration files.

Yooooomi avatar Sep 28 '22 15:09 Yooooomi

@Dhruvgera hello. I can't help you without any configuration files.

version: "3"

services:
  server:
    image: yooooomi/your_spotify_server
    restart: always
    ports:
      - "8080:8080"
    links:
      - mongo
    depends_on:
      - mongo
    environment:
      - API_ENDPOINT=http://spotify.xxx.app/api
      - CLIENT_ENDPOINT=http://spotify.xxx.app
      - SPOTIFY_PUBLIC=
      - SPOTIFY_SECRET=
      - CORS=all
  mongo:
    container_name: mongo
    image: mongo:4.4.8
    restart: always
    volumes:
      - ./your_spotify_db:/data/db

  web:
    image: yooooomi/your_spotify_client
    restart: always
    ports:
      - "3000:3000"
    environment:
      - API_ENDPOINT=http://spotify.xxx.app/api

This is my config, and I am having the same issue as @DarkKronicle did. The sign up works, but the blank black screen happens

Dhruvgera avatar Sep 28 '22 15:09 Dhruvgera

Sorry yeah mine is working perfect now! This project is awesome!

I don't know exactly what fixed it, though I think it was docker just being a bit jank. Turning off/on/deleting the containers fixed it. Seems that docker kept an old config.

DarkKronicle avatar Sep 28 '22 16:09 DarkKronicle

Sorry yeah mine is working perfect now! This project is awesome!

I don't know exactly what fixed it, though I think it was docker just being a bit jank. Turning off/on/deleting the containers fixed it. Seems that docker kept an old config.

Unfortunately for me, I am not being lucky with it. I've tried creating this across 3 servers and local machines, and re-setup multiple times to no avail

Dhruvgera avatar Sep 28 '22 16:09 Dhruvgera

Can you try having a different subdomain for the api?

Yooooomi avatar Sep 28 '22 19:09 Yooooomi

In my case it seemed that the URL used by the frontend's login button was somehow cached somewhere as after changing the URL in the docker container and recreating it, it stayed the same in the browser I've been using but was correctly updated in an incognito window. I dug in the source code to figure out where that URL was coming from.

The login button: https://github.com/Yooooomi/your_spotify/blob/fc31ae7516e22bd0b6a0ef951f5228b4baed1724/client/src/scenes/Account/Login/Login.tsx#L28 uses the function getSpotifyLogUrl(): https://github.com/Yooooomi/your_spotify/blob/fc31ae7516e22bd0b6a0ef951f5228b4baed1724/client/src/services/tools.ts#L22

As you can see the URL is stored in the window object. What is the reason for using that object specifically? In my case it doesn't get cleared by removing the cache and clearing the cookies, causing the issue with the URL not updating properly. The login URL only updated after I manually ran delete window.API_ENDPOINT from the Developer Tools' console.

Keagel avatar Nov 23 '22 18:11 Keagel

Hello, what's the state of this issue?

Yooooomi avatar Dec 12 '22 18:12 Yooooomi

I have the same issue. Clearing cache does not help.

batcatsaga avatar Dec 22 '22 11:12 batcatsaga

@batcatsaga Hello, can you open an issue with your configuration file and logs please?

Yooooomi avatar Dec 22 '22 15:12 Yooooomi