SaxyPandaBear / TwitchSongRequests

An unofficial Twitch integration that uses channel point redemption events to trigger enqueuing song requests in a connected Spotify player.
MIT License
14 stars 5 forks source link

[Bug]: 404 page not found #308

Closed Sacti00n closed 2 months ago

Sacti00n commented 2 months ago

What happened?

Hello, i deployed this Service on Railway, but when i try to click a button i get redirected to 404 page not found. It seems like it redirects wrong. redirect e.g.: example.com/oauth/example.com

What part of the service is not working for you?

No response

SaxyPandaBear commented 2 months ago

Thanks for trying out the template. What is the URL its trying to redirect to? I haven't tried using the template so I'm sure there's kinks to work out

Sacti00n commented 2 months ago

I deployed it on the url https://sacti0nsongrequests-production.up.railway.app/ . It redirects you to the Error 404 Site ( https://sacti0nsongrequests-production.up.railway.app/oauth/sacti0nsongrequests-production.up.railway.app )when you try to connect twitch or spotify, but when you reload the mainpage you are logged in. But you cant acces to the subscribe page cause it redirects you to https://sacti0nsongrequests-production.up.railway.app/sacti0nsongrequests-production.up.railway.app/subscribe

SaxyPandaBear commented 2 months ago

How familiar are you with railway? It should have the server logs. But if you're getting a 404, I'm not sure what's up or from what.

SaxyPandaBear commented 2 months ago

The redirect URL looks messed up. It looks like you set an env var wrong so it's nesting the URL.

Sacti00n commented 2 months ago

Ive never used it before but if you mean the Deploy Logs, there just stands "Served"

SaxyPandaBear commented 2 months ago

So https://sacti0nsongrequests-production.up.railway.app/oauth/sacti0nsongrequests-production.up.railway.app looks weird. The API endpoint for the app is /oauth/twitch and /oauth/spotify so it should be https://sacti0nsongrequests-production.up.railway.app/oauth/twitch etc etc

SaxyPandaBear commented 2 months ago

This is most likely configured in your environment variable for the twitch and spotify redirect URL, which I believe I refactored so you dont need to set those values anymore if you're hosting on railway because I can derive the URL from the base domain

Sacti00n commented 2 months ago

Ive just added some variables for database connection the port and Spotify/Twitch Client ID/Secret and ive added some random passphrases to twitch_secret, twitch_state & spotify_state

Sacti00n commented 2 months ago

Okay i fixed it. I added the SITE_REDIRECT_URL, TWITCH_REDIRECT_URL & SPOTIFY_REDIRECT_URL variable.

SaxyPandaBear commented 2 months ago

Okay that's good to know. I'll have to figure out why it couldn't derive the url properly though cause I feel like it should have worked. Thanks for your patience and quick responses! I'll update the docs around needing those, for now I guess though I really tried to make those variables obsolete

SaxyPandaBear commented 2 months ago

If you don't mind me asking, what is the value for your RAILWAY_PUBLIC_DOMAIN environment variable? I'm still confused why it didn't work for you without specifying the redirect URLs explicitly.

What this seems to point to, considering how I wrote this part specifically,

    railwayDomain, err := GetFromEnv(constants.RailwayDomain)
    if err == nil {
        redirectURL = fmt.Sprintf("https://%s/oauth/twitch", railwayDomain)
    } else {
        redirectURL = GetFromEnvOrDefault(constants.TwitchRedirectURL, "localhost:8000/oauth/twitch")
    }

Is if it didn't work at all without you specifying the TWITCH_REDIRECT_URL, I'm starting to think that the "provided" variable from Railway doesn't actually get injected into the environment unless you do so manually (which would suck)

Sacti00n commented 2 months ago

My RAILWAY_PUBLIC_DOMAIN variable is sacti0nsongrequests-production.up.railway.app

SaxyPandaBear commented 2 months ago

Yeah that should have worked then. I will try to troubleshoot I guess. Thanks for confirming