Prettier format pending files

This commit is contained in:
Builder.io 2025-11-10 01:17:20 +00:00
parent 5ce8cbf15d
commit 14313a08bf
7 changed files with 173 additions and 64 deletions

View file

@ -84,7 +84,8 @@ export default function Activity() {
🎮 Discord Activity
</h1>
<p className="text-gray-300 mb-8">
This page is designed to run as a Discord Activity. Open it within Discord to get started!
This page is designed to run as a Discord Activity. Open it within
Discord to get started!
</p>
<p className="text-gray-500 text-sm">
Not in Discord? Visit the main app at{" "}
@ -135,7 +136,8 @@ export default function Activity() {
<div className="bg-blue-900/20 border border-blue-700 rounded-lg p-3 mb-6">
<p className="text-blue-300 text-xs">
💡 Open Discord DevTools (Ctrl+Shift+I) and check the console for messages starting with{" "}
💡 Open Discord DevTools (Ctrl+Shift+I) and check the console for
messages starting with{" "}
<code className="bg-blue-950 px-1 rounded">
[Discord Activity]
</code>
@ -204,7 +206,9 @@ export default function Activity() {
realm-specific features.
</p>
<button
onClick={() => window.open(`${appBaseUrl}/profile/settings`, "_blank")}
onClick={() =>
window.open(`${appBaseUrl}/profile/settings`, "_blank")
}
className="mt-4 px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors"
>
Change Realm
@ -224,13 +228,17 @@ export default function Activity() {
🎨 Browse Creators
</button>
<button
onClick={() => window.open(`${appBaseUrl}/opportunities`, "_blank")}
onClick={() =>
window.open(`${appBaseUrl}/opportunities`, "_blank")
}
className="p-4 bg-gray-700 hover:bg-gray-600 rounded-lg text-white text-center transition-colors font-medium"
>
💼 Find Opportunities
</button>
<button
onClick={() => window.open(`${appBaseUrl}/profile/settings`, "_blank")}
onClick={() =>
window.open(`${appBaseUrl}/profile/settings`, "_blank")
}
className="p-4 bg-gray-700 hover:bg-gray-600 rounded-lg text-white text-center transition-colors font-medium"
>
Settings
@ -241,9 +249,17 @@ export default function Activity() {
<div className="bg-blue-900/20 border border-blue-700 rounded-lg p-4">
<p className="text-blue-100 text-sm">
💡 <strong>Discord Commands:</strong> Use{" "}
<code className="bg-blue-950 px-2 py-1 rounded text-xs">/profile</code>,{" "}
<code className="bg-blue-950 px-2 py-1 rounded text-xs">/set-realm</code>, and{" "}
<code className="bg-blue-950 px-2 py-1 rounded text-xs">/verify-role</code>{" "}
<code className="bg-blue-950 px-2 py-1 rounded text-xs">
/profile
</code>
,{" "}
<code className="bg-blue-950 px-2 py-1 rounded text-xs">
/set-realm
</code>
, and{" "}
<code className="bg-blue-950 px-2 py-1 rounded text-xs">
/verify-role
</code>{" "}
to manage your account directly in Discord.
</p>
</div>

View file

@ -7,16 +7,19 @@ This checklist ensures your Discord Activity meets Discord's Single-Page Applica
### Activity Component (code/client/pages/Activity.tsx)
- [ ] **No React Router Navigation**
- [ ] No `useNavigate()` hook
- [ ] No `navigate()` calls
- [ ] No `<Link to="...">` components
- [ ] **No Internal Page Navigation**
- [ ] All internal navigation removed
- [ ] Routes like `/creators`, `/opportunities`, `/settings` don't exist in Activity
- [ ] If accessing main app features, use `window.open(url, "_blank")`
- [ ] **Proper Error Handling**
- [ ] Graceful error state display
- [ ] Loading state handled properly
- [ ] "Not in Discord" state shows helpful message instead of crashing
@ -29,11 +32,13 @@ This checklist ensures your Discord Activity meets Discord's Single-Page Applica
### Manifest Configuration (code/public/discord-manifest.json)
- [ ] **Discord Proxy Domain Only**
- [ ] `rpc_origins` contains ONLY: `"https://578971245454950421.discordsays.com"`
- [ ] No external domains listed
- [ ] No `aethex.dev` in rpc_origins
- [ ] **Valid JSON Structure**
- [ ] `id` matches Discord app ID: `"578971245454950421"`
- [ ] `version` is set: `"1"`
- [ ] `name` describes the Activity
@ -46,12 +51,14 @@ This checklist ensures your Discord Activity meets Discord's Single-Page Applica
### Context/SDK Setup (code/client/contexts/DiscordActivityContext.tsx)
- [ ] **Proper SDK Initialization**
- [ ] SDK imported: `@discord/embedded-app-sdk`
- [ ] `DiscordSDK` instantiated with client ID
- [ ] `sdk.ready()` awaited before using SDK
- [ ] `sdk.authenticate()` called after ready
- [ ] **Correct OAuth Flow**
- [ ] Uses `sdk.commands.authorize()` for OAuth
- [ ] Exchanges code for token via `/api/discord/activity-auth`
- [ ] Token used to authenticate with SDK
@ -68,10 +75,11 @@ This checklist ensures your Discord Activity meets Discord's Single-Page Applica
### Link Handling
- [ ] **All External Links Use window.open()**
```typescript
// ✅ CORRECT
<button onClick={() => window.open(url, "_blank")}>
// ❌ WRONG
<a href={url}>
<Link to={url}>
@ -79,6 +87,7 @@ This checklist ensures your Discord Activity meets Discord's Single-Page Applica
```
- [ ] **All Buttons Have Clear Intent**
- [ ] "View Profile" → Opens profile in new window
- [ ] "Browse Creators" → Opens main app in new window
- [ ] "Settings" → Opens settings in new window
@ -93,6 +102,7 @@ This checklist ensures your Discord Activity meets Discord's Single-Page Applica
### User Data
- [ ] **Data Fetched from Backend**
- [ ] Uses `/api/discord/activity-auth` endpoint
- [ ] Passes access token from SDK
- [ ] Displays cached/static data, not real-time
@ -108,12 +118,14 @@ This checklist ensures your Discord Activity meets Discord's Single-Page Applica
### Pre-Deployment
- [ ] **Build Succeeds**
```bash
npm run build
# Should produce no errors about Activity
```
- [ ] **Dev Server Works**
```bash
npm run dev
# Activity loads without console errors
@ -127,11 +139,13 @@ This checklist ensures your Discord Activity meets Discord's Single-Page Applica
### Post-Deployment
- [ ] **Manifest Served Correctly**
- [ ] `https://aethex.dev/discord-manifest.json` returns valid JSON
- [ ] Content-Type is `application/json`
- [ ] No 404 errors
- [ ] **Activity Loads in Discord**
- [ ] Can launch from Discord
- [ ] No loading stuck state
- [ ] User profile displays
@ -168,6 +182,7 @@ This checklist ensures your Discord Activity meets Discord's Single-Page Applica
## 🔍 Verification Steps
### Step 1: Code Review
```bash
# Check Activity component
grep -n "navigate\|useNavigate\|<Link\|href=" code/client/pages/Activity.tsx
@ -179,6 +194,7 @@ grep -n "react-router" code/client/pages/Activity.tsx
```
### Step 2: Manifest Validation
```bash
# Check manifest domains
cat code/public/discord-manifest.json
@ -187,6 +203,7 @@ cat code/public/discord-manifest.json
```
### Step 3: Runtime Testing
1. Launch Activity in Discord
2. Open DevTools (F12)
3. Check console for `[Discord Activity]` logs
@ -195,6 +212,7 @@ cat code/public/discord-manifest.json
6. Reload Activity - should re-initialize properly
### Step 4: Cross-Origin Testing
1. In Discord DevTools:
- Go to Console tab
- Look for CORS errors
@ -205,14 +223,14 @@ cat code/public/discord-manifest.json
## Common Issues & Fixes
| Issue | Cause | Fix |
|-------|-------|-----|
| Activity won't load | Missing frame_id in URL | Check you're in Discord iframe |
| "Cannot find module 'react-router'" | Router still imported | Remove router imports |
| Links navigate within Activity | Using `href` or `navigate()` | Change to `window.open(..., "_blank")` |
| User data doesn't load | `/api/discord/activity-auth` failing | Check SDK authentication success |
| CORS errors in console | External domains in rpc_origins | Remove from manifest, use Discord proxy |
| Manifest 404 error | File not in public directory | Move to `code/public/discord-manifest.json` |
| Issue | Cause | Fix |
| ----------------------------------- | ------------------------------------ | ------------------------------------------- |
| Activity won't load | Missing frame_id in URL | Check you're in Discord iframe |
| "Cannot find module 'react-router'" | Router still imported | Remove router imports |
| Links navigate within Activity | Using `href` or `navigate()` | Change to `window.open(..., "_blank")` |
| User data doesn't load | `/api/discord/activity-auth` failing | Check SDK authentication success |
| CORS errors in console | External domains in rpc_origins | Remove from manifest, use Discord proxy |
| Manifest 404 error | File not in public directory | Move to `code/public/discord-manifest.json` |
## Certification Summary

View file

@ -26,15 +26,18 @@ Discord Client
## Key Changes from Previous Implementation
### 1. **Removed Router Navigation**
- **Before:** Activity used `useNavigate()` to redirect within React Router
- **After:** Activity is completely self-contained, no internal navigation
### 2. **Links Now Open in New Windows**
- **Before:** `<a href="/creators">` navigated within the iframe
- **After:** `<button onClick={() => window.open(url, "_blank")}>` opens the main app in a new tab
- This allows users to see full features without breaking Activity isolation
### 3. **Simplified Manifest**
- **Before:** Manifest referenced multiple domains including aethex.dev
- **After:** Manifest ONLY references Discord proxy domain (`578971245454950421.discordsays.com`)
- This ensures Activity is properly sandboxed through Discord's proxy
@ -44,6 +47,7 @@ Discord Client
### code/client/pages/Activity.tsx
**Removed:**
```typescript
import { useNavigate } from "react-router-dom";
const navigate = useNavigate();
@ -55,6 +59,7 @@ useEffect(() => {
```
**Added:**
```typescript
import { useState } from "react";
const [showContent, setShowContent] = useState(false);
@ -67,6 +72,7 @@ useEffect(() => {
```
**Link Changes:**
```typescript
// Before:
<a href="/creators" className="...">🎨 Browse Creators</a>
@ -83,6 +89,7 @@ useEffect(() => {
### code/public/discord-manifest.json
**Before:**
```json
{
"rpc_origins": [
@ -98,11 +105,10 @@ useEffect(() => {
```
**After:**
```json
{
"rpc_origins": [
"https://578971245454950421.discordsays.com"
]
"rpc_origins": ["https://578971245454950421.discordsays.com"]
}
```
@ -134,11 +140,13 @@ useEffect(() => {
### Local Testing
1. Start the dev server:
```bash
npm run dev
```
2. Open Discord and find an Activity that can be launched
- Right-click on a voice channel
- Select "Launch Activity"
- Look for "AeThex Activity"
@ -152,6 +160,7 @@ useEffect(() => {
### Deployment Testing
1. After deploying to production:
```bash
npm run build
npm start
@ -169,10 +178,13 @@ If you want to add more features to the Activity without breaking isolation, use
```typescript
// Activity sends message to parent window (if applicable)
if (window.opener) {
window.opener.postMessage({
type: 'navigate',
path: '/opportunities'
}, 'https://aethex.dev');
window.opener.postMessage(
{
type: "navigate",
path: "/opportunities",
},
"https://aethex.dev",
);
}
```
@ -185,9 +197,7 @@ If Activity needs to access external APIs, update the manifest:
"interactions": {
"request_url": "https://aethex.dev/api/discord/interactions"
},
"rpc_origins": [
"https://578971245454950421.discordsays.com"
],
"rpc_origins": ["https://578971245454950421.discordsays.com"],
"url_mapping": {
"/api/external": "https://api.external-service.com",
"/uploads": "https://cdn.aethex.dev/uploads"
@ -196,8 +206,9 @@ If Activity needs to access external APIs, update the manifest:
```
Then in code, use relative paths:
```typescript
fetch('/api/external/data') // Discord proxy transforms to https://api.external-service.com/data
fetch("/api/external/data"); // Discord proxy transforms to https://api.external-service.com/data
```
## Troubleshooting
@ -211,7 +222,7 @@ fetch('/api/external/data') // Discord proxy transforms to https://api.external-
### Links Not Working
1. **Ensure target="_blank" or window.open()** - Regular navigation breaks Activity
1. **Ensure target="\_blank" or window.open()** - Regular navigation breaks Activity
2. **Check URL construction** - Verify full URL is correct
3. **Test in separate browser tab** - Verify links work outside Activity
@ -229,7 +240,7 @@ fetch('/api/external/data') // Discord proxy transforms to https://api.external-
- [ ] Backend OAuth endpoints configured (/api/discord/activity-auth)
- [ ] Discord Developer Portal has manifest URL configured
- [ ] Test server has AeThex bot installed
- [ ] All links use window.open() with "_blank" target
- [ ] All links use window.open() with "\_blank" target
- [ ] No React Router navigation in Activity component
## Related Documentation

View file

@ -13,12 +13,14 @@ All Discord linking flow issues have been identified and fixed. This document su
**File:** `code/client/pages/DiscordVerify.tsx` (Line 91-93)
**What was broken:**
- After `/verify` command in Discord, user clicks link
- Code auto-submits successfully
- Code auto-submits successfully
- BUT redirected to `/profile/settings` (wrong page)
- User can't see Discord in connections list
**What was fixed:**
```typescript
// BEFORE
setTimeout(() => {
@ -40,6 +42,7 @@ setTimeout(() => {
**File:** `code/client/pages/DiscordVerify.tsx` (Lines 160, 228)
**What was broken:**
- "Go to Settings" button on success screen → `/profile/settings`
- "Cancel" button on input screen → `/profile/settings`
- Both sent users to wrong location
@ -47,6 +50,7 @@ setTimeout(() => {
**What was fixed:**
Button 1 (Line 160):
```typescript
// BEFORE
onClick={() => navigate("/profile/settings")}
@ -56,6 +60,7 @@ onClick={() => navigate("/dashboard?tab=connections")}
```
Button 2 (Line 228):
```typescript
// BEFORE
onClick={() => navigate("/profile/settings")}
@ -73,11 +78,13 @@ onClick={() => navigate("/dashboard")}
**File:** `code/api/discord/oauth/callback.ts` (Lines 105-113)
**What was broken:**
- When session lost, error message was generic: "Please sign in before linking Discord"
- No diagnostic information to help debug
- Users didn't know what went wrong
**What was fixed:**
```typescript
// BEFORE
console.error("[Discord OAuth] Linking flow but no authenticated user found");
@ -86,9 +93,16 @@ return res.redirect(
);
// AFTER
console.error("[Discord OAuth] Linking flow but no authenticated user found - session cookies not present in request");
console.error("[Discord OAuth] DIAGNOSTIC: Ensure Discord Dev Portal OAuth2 Redirects includes:", "https://aethex.dev/api/discord/oauth/callback");
console.error("[Discord OAuth] If using custom domain, update the redirect URI accordingly");
console.error(
"[Discord OAuth] Linking flow but no authenticated user found - session cookies not present in request",
);
console.error(
"[Discord OAuth] DIAGNOSTIC: Ensure Discord Dev Portal OAuth2 Redirects includes:",
"https://aethex.dev/api/discord/oauth/callback",
);
console.error(
"[Discord OAuth] If using custom domain, update the redirect URI accordingly",
);
return res.redirect(
`/login?error=session_lost&message=${encodeURIComponent("Your session was lost. Please sign in again and try linking Discord.")}`,
);
@ -103,6 +117,7 @@ return res.redirect(
### Session Loss During Dashboard OAuth Linking
**What happens:**
1. User on `/dashboard?tab=connections`
2. Clicks "Link Discord" button
3. Redirected to Discord OAuth
@ -112,13 +127,14 @@ return res.redirect(
7. Backend can't extract user_id from cookies
8. User redirected to login
**Root cause:**
**Root cause:**
One of the following:
1. **Redirect URI not registered in Discord Dev Portal** ← MOST LIKELY
- Discord doesn't redirect to the correct URL
- Causes issues with cookie handling
2. Browser cookie policy (SameSite=Lax)
- Cookies might not be sent in cross-site redirect
- Less likely but possible
@ -186,6 +202,7 @@ Expected flow:
```
**Status:** ⚠️ DEPENDS ON - Discord Dev Portal configuration
- If redirect URI not registered: User redirected to login
- Fix: Verify Discord Dev Portal has correct redirect URI registered (see step above)
@ -207,11 +224,13 @@ Expected when trying to link again:
## 📚 Documentation Created
1. **DISCORD-LINKING-FLOW-ANALYSIS.md**
- Complete flow diagrams
- Issue breakdown
- Root cause analysis
2. **DISCORD-OAUTH-SETUP-VERIFICATION.md** ← READ THIS NEXT
- Step-by-step Discord Dev Portal verification
- Testing procedures
- Debugging guide
@ -236,12 +255,14 @@ Expected when trying to link again:
## Environment Variables Required
### Already Set ✅
- `DISCORD_CLIENT_ID=578971245454950421`
- `DISCORD_PUBLIC_KEY=...`
- `VITE_SUPABASE_URL=...`
- `VITE_SUPABASE_ANON_KEY=...`
### Verify These Are Set ⚠️
- `DISCORD_CLIENT_SECRET` (set in production only)
- `SUPABASE_SERVICE_ROLE` (set in production only)
- `VITE_API_BASE` (correct domain for your deployment)
@ -250,30 +271,31 @@ Expected when trying to link again:
## Code Changes Summary
| File | Change | Status |
|------|--------|--------|
| `code/client/pages/DiscordVerify.tsx` | Lines 91-93: Auto-redirect to connections tab | ✅ FIXED |
| `code/client/pages/DiscordVerify.tsx` | Line 160: Button redirect to connections tab | ✅ FIXED |
| `code/client/pages/DiscordVerify.tsx` | Line 228: Cancel button redirect to dashboard | ✅ FIXED |
| `code/api/discord/oauth/callback.ts` | Lines 105-113: Better error messages | ✅ IMPROVED |
| Discord Dev Portal | OAuth2 Redirect URI registration | ⚠️ NEEDS VERIFICATION |
| File | Change | Status |
| ------------------------------------- | --------------------------------------------- | --------------------- |
| `code/client/pages/DiscordVerify.tsx` | Lines 91-93: Auto-redirect to connections tab | ✅ FIXED |
| `code/client/pages/DiscordVerify.tsx` | Line 160: Button redirect to connections tab | ✅ FIXED |
| `code/client/pages/DiscordVerify.tsx` | Line 228: Cancel button redirect to dashboard | ✅ FIXED |
| `code/api/discord/oauth/callback.ts` | Lines 105-113: Better error messages | ✅ IMPROVED |
| Discord Dev Portal | OAuth2 Redirect URI registration | ⚠️ NEEDS VERIFICATION |
---
## Issue Resolution Status
| Issue | Status | Solution |
|-------|--------|----------|
| Wrong redirect after /verify | ✅ FIXED | Update code + deploy |
| Session lost during OAuth | ⚠️ PARTIALLY FIXED | Need Discord Dev Portal verification |
| Generic error messages | ✅ IMPROVED | Better console logging |
| UI consistency | ✅ FIXED | All redirects now go to connections tab |
| Issue | Status | Solution |
| ---------------------------- | ------------------ | --------------------------------------- |
| Wrong redirect after /verify | ✅ FIXED | Update code + deploy |
| Session lost during OAuth | ⚠️ PARTIALLY FIXED | Need Discord Dev Portal verification |
| Generic error messages | ✅ IMPROVED | Better console logging |
| UI consistency | ✅ FIXED | All redirects now go to connections tab |
---
## Deployment Instructions
1. **Deploy code changes:**
```bash
npm run build
npm run deploy
@ -281,11 +303,13 @@ Expected when trying to link again:
```
2. **Verify Discord Dev Portal:**
- Follow steps in DISCORD-OAUTH-SETUP-VERIFICATION.md
- Add redirect URI if missing
- Wait for propagation
3. **Test thoroughly:**
- Test /verify flow
- Test Dashboard "Link Discord" button
- Check session persistence
@ -307,6 +331,7 @@ Expected when trying to link again:
## Questions?
Refer to:
1. **DISCORD-OAUTH-SETUP-VERIFICATION.md** - Setup & testing
2. **DISCORD-LINKING-FLOW-ANALYSIS.md** - Architecture & flow diagrams
3. Browser console - Look for `[Discord OAuth]` debug messages

View file

@ -26,7 +26,8 @@ Returns success response with discord username ✅
Should redirect to: /dashboard?tab=connections
```
**Why it's broken:**
**Why it's broken:**
- Line 92 of `DiscordVerify.tsx` hardcoded to navigate to `/profile/settings`
- User needs to see **Connections** tab to verify Discord was linked
- Shows wrong page, feels like "demo BS" or missing content
@ -64,11 +65,13 @@ Redirects to: /login?error=not_authenticated
```
**Why it's broken:**
1. Session cookies not being sent with OAuth callback request
2. OR session was cleared/expired during OAuth roundtrip
3. OR redirectUri mismatch causing issues
**Root cause:**
**Root cause:**
- Browser cookies might not be sent cross-domain
- SameSite=Lax might be blocking cookies
- The redirectUri registered in Discord Dev Portal might not match
@ -94,6 +97,7 @@ Never completes the linking
### Fix 1: DiscordVerify.tsx Redirect (Line 92)
**Current (WRONG):**
```typescript
setTimeout(() => {
navigate("/profile/settings");
@ -101,6 +105,7 @@ setTimeout(() => {
```
**Should be (CORRECT):**
```typescript
setTimeout(() => {
navigate("/dashboard?tab=connections");
@ -116,9 +121,10 @@ setTimeout(() => {
The `/api/discord/oauth/callback.ts` needs to ensure:
1. **SameSite Cookie Policy** - Cookies must be sent with cross-site requests
```typescript
// In oauth callback response headers
res.setHeader('Set-Cookie', [
res.setHeader("Set-Cookie", [
`sb-access-token=...; SameSite=None; Secure; Path=/`,
`sb-refresh-token=...; SameSite=None; Secure; Path=/`,
]);
@ -133,6 +139,7 @@ The `/api/discord/oauth/callback.ts` needs to ensure:
### Fix 3: Verify Discord OAuth Redirect URI
**In Discord Developer Portal:**
1. Go to Applications > Your App
2. OAuth2 > Redirects
3. Make sure this is listed:
@ -142,6 +149,7 @@ The `/api/discord/oauth/callback.ts` needs to ensure:
(Or whatever domain is in production)
**In Code:**
- `code/api/discord/oauth/start.ts` - Uses dynamic domain ✅
- `code/api/discord/oauth/callback.ts` - Uses dynamic domain ✅
@ -157,11 +165,14 @@ After successful linking, before redirecting:
// After successful link at line 225
if (isLinkingFlow && authenticatedUserId) {
// ... linking logic ...
// IMPORTANT: Set cookies explicitly for browser
// (Supabase session cookies should already be set, but ensure)
console.log("[Discord OAuth] Successfully linked, redirecting to:", redirectTo);
console.log(
"[Discord OAuth] Successfully linked, redirecting to:",
redirectTo,
);
return res.redirect(302, redirectTo); // Use 302 instead of default
}
```
@ -175,21 +186,25 @@ if (isLinkingFlow && authenticatedUserId) {
File: `code/client/pages/DiscordVerify.tsx`
Change line 92 from:
```typescript
navigate("/profile/settings");
```
To:
```typescript
navigate("/dashboard?tab=connections");
```
Also change the button on line 160 from:
```typescript
onClick={() => navigate("/profile/settings")}
```
To:
```typescript
onClick={() => navigate("/dashboard?tab=connections")}
```
@ -199,6 +214,7 @@ onClick={() => navigate("/dashboard?tab=connections")}
### Step 2: Verify Discord OAuth Redirect URI
Check Discord Developer Portal:
- Application: AeThex
- OAuth2 → Redirects
- Confirm this is registered: `https://aethex.dev/api/discord/oauth/callback`
@ -231,11 +247,12 @@ To help debug session issues, add logging in AuthContext:
File: `code/client/contexts/AuthContext.tsx`
In the useEffect that checks cookies, add:
```typescript
useEffect(() => {
// Debug: Log current session state
const cookies = document.cookie.split('; ').map(c => {
const [key] = c.split('=');
const cookies = document.cookie.split("; ").map((c) => {
const [key] = c.split("=");
return key;
});
console.log("[AuthContext] Available cookies:", cookies);
@ -282,12 +299,15 @@ useEffect(() => {
### Issue: Still Redirected to Login After Linking
**Possible causes:**
1. Session cookies not being sent
- Check: DevTools → Network → Find the OAuth callback request
- Look for "Cookie" header in request
- If missing, cookies might be blocked
2. OAuth Redirect URI mismatch
- Check: Discord Developer Portal OAuth2 redirects
- Should exactly match what backend is using
@ -296,6 +316,7 @@ useEffect(() => {
- Might need SameSite=None; Secure
**Debug steps:**
1. Open browser DevTools (F12)
2. Go to Network tab
3. Do the Discord link flow
@ -312,10 +333,13 @@ useEffect(() => {
### Issue: Discord Doesn't Show in Connections List
**Possible causes:**
1. Linking succeeded but user not refreshed
- Fix: Page reload or refreshAuthState() call
2. Discord link created but user lookup fails
- Check: Supabase discord_links table has the record
- Check: User ID matches in both tables
@ -327,11 +351,11 @@ useEffect(() => {
## File Changes Summary
| File | Change | Line(s) |
|------|--------|---------|
| File | Change | Line(s) |
| ------------------------------------- | ---------------------------------- | ------- |
| `code/client/pages/DiscordVerify.tsx` | Change redirect to connections tab | 92, 160 |
| `code/api/discord/oauth/callback.ts` | Add explicit status code | 225 |
| Discord Dev Portal | Verify redirect URI | N/A |
| `code/api/discord/oauth/callback.ts` | Add explicit status code | 225 |
| Discord Dev Portal | Verify redirect URI | N/A |
---

View file

@ -20,6 +20,7 @@ https://aethex.dev/api/discord/oauth/callback
```
**If you're using a different domain** (like localhost for testing):
```
http://localhost:5173/api/discord/oauth/callback
```
@ -37,6 +38,7 @@ If the URL is NOT listed:
4. **Wait** - changes may take 1-2 minutes to propagate
⚠️ **IMPORTANT:** The redirect URI must match EXACTLY:
- Correct: `https://aethex.dev/api/discord/oauth/callback`
- Wrong: `https://aethex.dev/api/discord/callback` (missing `/oauth`)
- Wrong: `aethex.dev/api/discord/oauth/callback` (missing `https://`)
@ -59,9 +61,11 @@ After verifying the redirect URI, test both flows:
7. 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
@ -81,12 +85,14 @@ This is the flow that had session loss issues.
8. **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
@ -100,12 +106,15 @@ Verify these are set correctly:
### Frontend (code/.env or deployment platform)
- [ ] `VITE_API_BASE` is set to your API domain
```
VITE_API_BASE=https://aethex.dev
```
(Or your actual deployment domain)
- [ ] `VITE_SUPABASE_URL` is correct
```
VITE_SUPABASE_URL=https://kmdeisowhtsalsekkzqd.supabase.co
```
@ -115,17 +124,21 @@ Verify these are set correctly:
### Backend/Server (environment variables)
- [ ] `DISCORD_CLIENT_ID` is set
```
DISCORD_CLIENT_ID=578971245454950421
```
- [ ] `DISCORD_CLIENT_SECRET` is set (production)
```
DISCORD_CLIENT_SECRET=JKlilGzcTWgfmt2wEqiHO8wpCel5VEji
```
⚠️ **NOTE:** This is sensitive - only set in production, not in code
- [ ] `VITE_SUPABASE_URL` is set on backend
```
VITE_SUPABASE_URL=https://kmdeisowhtsalsekkzqd.supabase.co
```
@ -145,6 +158,7 @@ Verify these are set correctly:
**Cause:** Redirect URI not registered in Discord Dev Portal
**Solution:**
1. Open Discord Developer Portal
2. Go to OAuth2 → Redirects
3. Verify `https://aethex.dev/api/discord/oauth/callback` is listed
@ -158,6 +172,7 @@ Verify these are set correctly:
**Cause:** Linking succeeded but auth state not refreshed
**Solution:**
1. Verify the `discord_links` table in Supabase has the record
- Go to: https://app.supabase.com/project/kmdeisowhtsalsekkzqd
- Find table: `discord_links`
@ -177,6 +192,7 @@ Verify these are set correctly:
**Old Problem:** Redirected to `/profile/settings`
**Solution:** ✅ FIXED in code
- The code now redirects to `/dashboard?tab=connections`
- If you're still seeing `/profile/settings`:
- Clear browser cache (Ctrl+Shift+Delete)
@ -189,6 +205,7 @@ Verify these are set correctly:
**Cause:** 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 `\unlink` command to disconnect it, then `/verify` again

View file

@ -3,7 +3,5 @@
"version": "1",
"name": "AeThex Activity",
"description": "AeThex Creator Network & Talent Platform - Discord Activity",
"rpc_origins": [
"https://578971245454950421.discordsays.com"
]
"rpc_origins": ["https://578971245454950421.discordsays.com"]
}