Closed benclarkk closed 5 years ago
idk if this is a good place to put this but
Looks like your DISCORD_OAUTH_ORIGINS
is incorrect. Try DISCORD_OAUTH_ORIGINS=http://ip:3000
.
Let me know if this works or if you have any other issues!
I've changed it to DISCORD_OAUTH_ORIGINS=http://myip:3000
, however it doesn't look like it's fixed the problem :(
here's my redirects on discord if that helps.
For the life of me I can't figure out why this is happening (something to do with dotenv parsing, or something overwriting the variable? I couldn't find anything), but _process.env.DISCORD_OAUTHORIGINS keeps returning '1,2' for me, regardless of what I set in the .env file
api/.env api/src/controllers/auth.controller.ts output
I fixed it for myself by just changing the name to 'DISCORD_OAUTH_ORIGIN' in the .env file and the auth controller, but that feels kinda kludgy.
In your Discord Application config, the only Redirect URL you should have is http://localhost:3000/auth/discord
if you're running locally. You shouldn't need DISCORD_OAUTH_ORIGIN
, and DISCORD_OAUTH_ORIGINS
should be set to http://localhost:3000
.
Let me know if this helps!
I'm running it remotely, and I think ben is too. I suspect his issue is the same one I was having.
DISCORD_OAUTH_ORIGINS
isn't returning the URI from the .env file when auth.controller asks for it, which causes it to return 401 when the origins don't match.
http://localhost:3000
will work for running locally, but only because it gets pushed to the origins array in the auth controller https://github.com/crybapp/api/blob/master/src/controllers/auth.controller.ts#L12
I'll try experiment with that to see if there is a better fix available
Does this fix any issues? https://github.com/crybapp/api/commit/032557e649d61a5a694269930b3ffd30fc41d483 @akunim
Still throws the 401 if I don't use a different env variable for setting origins
process.env.DISCORD_OAUTH_ORIGINS
still seems to be acting strange for me
dumping process.env when api launches, it looks like it's getting set earlier than the rest of the values in the .env file, but I'm not sure the significance of that
.env file https://gist.github.com/akunim/76b33d93edcd2b30fe4c16ebe3c24757
032557e fixes the issue for me, so that's strange. but thanks for the fix @williamsthing.
Fixed already. For support get to the Cryb Discord server.
hi, when logging in with discord, the web app shows
An error occured while authenticating. Please go home and Login with Discord again
, and the api logs showPOST /auth/discord 401 0.738 ms - 12
. Console logs: console-export-2019-10-15_19-5-5.txt My web env: https://gist.github.com/benclarkk/0795888dd5361dee7e9913aeb8b34ada My API env: https://gist.github.com/benclarkk/ba602a40abf25e4dc7f28a481fee0532