Discord OAuth Setup Verification Checklist
π΄ CRITICAL: OAuth Redirect URI Registration
This is the most common cause of session loss during Discord linking.
Step 1: Open Discord Developer Portal
Go to: https://discord.com/developers/applications
Find and click: AeThex application
Left sidebar, click: OAuth2
Find the section: REDIRECT URLS or REDIRECTS
Step 2: Verify Redirect URI is Registered
You must have this exact URL registered:
https://aethex.dev/api/discord/oauth/callbackIf you're using a different domain (like localhost for testing):
http://localhost:5173/api/discord/oauth/callbackStep 3: Add Missing Redirect URI (If Needed)
If the URL is NOT listed:
Click: Add Redirect button
Paste the correct URL:
https://aethex.dev/api/discord/oauth/callbackClick: Save Changes
Wait - changes may take 1-2 minutes to propagate
β οΈ IMPORTANT: The redirect URI must match EXACTLY:
Correct:
https://aethex.dev/api/discord/oauth/callbackWrong:
https://aethex.dev/api/discord/callback(missing/oauth)Wrong:
aethex.dev/api/discord/oauth/callback(missinghttps://)Wrong:
https://aethex.dev/api/discord/oauth/callback/(trailing slash)
π’ TESTING THE DISCORD LINKING FLOWS
After verifying the redirect URI, test both flows:
Test Flow 1: Discord /verify Command
/verify CommandIn Discord, type:
/verifyClick the link button or copy the code
Browser opens:
https://aethex.dev/discord-verify?code=XXXXXXPage auto-submits and links your account
You should see: β Success message
Redirects to:
/dashboard?tab=connections(FIXED)You should see Discord in your connections list
If it redirects to /profile/settings instead:
This has been FIXED in the code update
If it shows an error:
Check the error message in the browser console
Note: Session may be lost if redirect URI not registered
Test Flow 2: Dashboard "Link Discord" Button
This is the flow that had session loss issues.
Go to:
/dashboard?tab=connectionsClick: Link Discord button
You'll be redirected to Discord OAuth
Click: Authorize on Discord
Discord redirects back to your app
EXPECTED: You should be redirected to
/dashboard?tab=connectionsEXPECTED: You should still be logged in
EXPECTED: Discord should appear in your connections
If you're redirected to /login instead:
Session was lost during OAuth callback
Cause: Redirect URI not registered in Discord Dev Portal
Solution: Follow Step 1-3 above to add the redirect URI
Then: Try the flow again
If you see an error about session being lost:
This means the backend detected missing session cookies
Check the browser console for error details
The error message now tells you to verify Discord Dev Portal settings
π΅ ENVIRONMENT VARIABLES CHECKLIST
Verify these are set correctly:
Frontend (code/.env or deployment platform)
Backend/Server (environment variables)
π‘ COMMON ISSUES & SOLUTIONS
Issue 1: "Session Lost" Error After Discord OAuth
Cause: Redirect URI not registered in Discord Dev Portal
Solution:
Open Discord Developer Portal
Go to OAuth2 β Redirects
Verify
https://aethex.dev/api/discord/oauth/callbackis listedIf not listed, add it and save
Try the linking flow again (may need to clear browser cache first)
Issue 2: Discord Link Disappears After Page Reload
Cause: Linking succeeded but auth state not refreshed
Solution:
Verify the
discord_linkstable in Supabase has the recordGo to: https://app.supabase.com/project/kmdeisowhtsalsekkzqd
Find table:
discord_linksCheck if your discord_id and user_id are recorded
If record exists but not showing in UI:
Reload the page or go to
/dashboardThe UI should refresh and show Discord connection
If record doesn't exist:
The linking failed silently
Check browser console for errors
Try the
/verifyflow instead
Issue 3: Wrong Redirect Page After /verify Command
/verify CommandOld Problem: Redirected to /profile/settings
Solution: β FIXED in code
The code now redirects to
/dashboard?tab=connectionsIf you're still seeing
/profile/settings:Clear browser cache (Ctrl+Shift+Delete)
Deploy the latest code changes
Issue 4: "Already Linked" Error in /verify Command
/verify CommandCause: Discord account already linked to an AeThex account
Solutions:
Option A: Use a different Discord account
Option B: Contact admin to unlink the Discord account from the other AeThex account
Option C: If it's your old account, use
\unlinkcommand to disconnect it, then/verifyagain
π£ DEBUGGING STEPS
If something isn't working, follow these steps:
Step 1: Check Browser Console
Open Discord or your app
Press F12 (DevTools)
Go to Console tab
Look for messages starting with
[Discord OAuth]or[Discord Activity]Take a screenshot of any error messages
Step 2: Check Network Tab
In DevTools, go to Network tab
Perform the Discord linking flow
Look for a request to
/api/discord/oauth/callback?code=...Click on it and check:
Request Headers β
Cookie(should havesb-access-token)Response Headers β
Set-Cookie(should have new tokens)Status β Should be
302(redirect)
Step 3: Check Supabase
Go to: https://app.supabase.com/project/kmdeisowhtsalsekkzqd
Find table:
discord_linksLook for your discord_id (check if record exists)
If record exists but UI doesn't show it:
Reload the page
Or manually call
refreshAuthState()
If record doesn't exist:
Linking never succeeded
Check the Network tab request/response above
Step 4: Check Discord Dev Portal
Go to: https://discord.com/developers/applications/578971245454950421
Click: OAuth2
Scroll to: REDIRECT URLS
Verify:
https://aethex.dev/api/discord/oauth/callbackis listedIf missing:
Add it
Save
Wait 1-2 minutes
Try linking again
β
Verification Checklist
When everything is working correctly, you should see:
When all items are checked, your Discord linking is fully functional! π
Related Documentation
DISCORD-LINKING-FLOW-ANALYSIS.md - Flow diagrams and architecture
DISCORD-ACTIVITY-SETUP.md - Discord Activity/slash commands setup
DISCORD-ADMIN-COMMANDS-REGISTRATION.md - Bot command registration
Last updated
