ACTION PLAN IMMEDIATE

Documentation for Plans

⚡ IMMEDIATE ACTION PLAN

Date: October 31, 2025
Time: 4:10 PM
Status: 🚨 URGENT - 3 Critical Issues
Purpose: Fix space slug and API connectivity


🔴 Critical Issues from Logs

Issue #1: Space Slug Still Wrong ❌

spaceSlug: 'editor'  // ❌ Wrong!
name: 'My space'     // ✅ Correct

Root Cause: Old cached data in IndexedDB with incorrect slug.

Issue #2: Backend API Failing ⚠️

[SpaceService] 🌐 Initializing from API...
[SpaceService] 📦 Using local storage (offline mode)  // API failed!

Root Cause: Backend API not responding or not running.

Issue #3: Incorrect Slug Used in URL 🔗

URL: http://localhost:5200/editor/dashboard
Expected: http://localhost:5200/my-space/dashboard

✅ Action Steps (In Order)

Step 1: Clear Cached Space Data (30 seconds)

Open browser console (F12) and run:

clearCachedSpaceData()

Expected output:

🧹 Starting cache cleanup...
📦 Clearing localStorage...
  ✅ Removing: space_68fbe3ac4740d821e041f9df
✅ Removed 15 items from localStorage
🗄️  Clearing IndexedDB...
✅ Deleted IndexedDB: gograb-space
✅ sessionStorage cleared

🎉 Cache cleanup complete!
🔄 Please refresh the page to recreate space with correct slug.

Then refresh (Cmd+R / F5)


Step 2: Verify Backend API is Running

Check if backend is running:

# Terminal 1 - Check if backend-api is running
# Look for "backend-api:serve" in your terminal tabs
# Port should be 3000

If NOT running, start it:

cd /Users/fguijarro/developer/repos/editor
nx serve backend-api

Verify backend is accessible:

# Test health endpoint
curl http://localhost:3000/api/health

# Expected response:
# {"status":"ok","timestamp":"...","uptime":123.45}

Step 3: Test Backend API Connection

In browser console:

// Test backend connection
fetch('https://backend-api-production-97c0.up.railway.app/api/health')
  .then(r => r.json())
  .then(d => console.log('✅ Backend reachable:', d))
  .catch(e => console.error('❌ Backend unreachable:', e));

If connection fails:

  1. Check if Railway backend is deployed
  2. Check CORS configuration
  3. Try local backend instead: http://localhost:3000

Step 4: Update Environment to Use Local Backend (If Railway Fails)

Edit: apps/gograb-space/src/environments/environment.ts

import { SHARED_CONFIG, BACKEND_URLS } from './environment.shared';

export const environment = {
  production: false,
  
  // 🔥 Change this to use local backend
  useMockApi: false,
  backendApiUrl: BACKEND_URLS.local,  // ✅ Use local instead of Railway
  
  ...SHARED_CONFIG,
};

Then restart frontend (it will auto-reload)


Step 5: Verify Space Slug After Refresh

After clearing cache and refreshing, check logs for:

✅ CORRECT:
spaceSlug: 'my-space'  // ✅ Generated from "My space"
name: 'My space'

❌ WRONG (still):
spaceSlug: 'editor'    // ❌ From URL

Check in console:

// Get current space
const space = window.__spaceService__?.currentSpace?.();
console.log('Space:', {
  name: space?.name,
  slug: space?.spaceSlug,
  isCorrect: space?.spaceSlug === 'my-space'
});

// Should show:
// { name: 'My space', slug: 'my-space', isCorrect: true }

Step 6: Navigate to Correct URL

Once slug is fixed, navigate to:

http://localhost:5200/my-space/dashboard

NOT:

http://localhost:5200/editor/dashboard  // ❌ Wrong!

🔍 Troubleshooting

If clearCachedSpaceData() doesn't work

Run manually in console:

// Clear localStorage
Object.keys(localStorage).forEach(key => {
  if (key.includes('space_') || key.includes('gg:') || key.includes('flash:')) {
    console.log('Deleting:', key);
    localStorage.removeItem(key);
  }
});

// Clear IndexedDB
indexedDB.deleteDatabase('gograb-space');

// Clear sessionStorage
sessionStorage.clear();

// Refresh
location.reload();

If Backend API Still Fails

Check backend logs for errors:

# Look in terminal running backend-api
# Check for:
# - MongoDB connection errors
# - JWT authentication errors
# - CORS errors

Common fixes:

  1. MongoDB not connected:

    Check .env file for MONGODB_CONNECTION_STRING
    
  2. JWT secret missing:

    Check .env file for JWT_SECRET
    
  3. CORS issue:

    Add localhost:5200 to ALLOWED_ORIGINS in .env
    

If Space Slug Still Wrong After Clear

This means the slug is coming from URL routing. Solution:

  1. Navigate to root: http://localhost:5200/
  2. Let the app redirect you automatically
  3. It should use the correct slug from the space

📊 Expected Results

After Step 1 (Clear Cache):

✅ No cached space data
✅ Fresh start

After Step 2 (Backend Running):

✅ Backend responding on port 3000
✅ Health endpoint returns OK

After Step 3 (API Connection):

✅ Backend reachable
✅ Authentication working
✅ Space API endpoints responding

After Step 5 (Verify Slug):

✅ Space name: "My space"
✅ Space slug: "my-space" (generated from name)
✅ URL: /my-space/dashboard

🎯 Success Criteria

All of these should be TRUE:


🚨 If All Else Fails

Nuclear option - Complete reset:

// 1. Clear everything
localStorage.clear();
sessionStorage.clear();
indexedDB.deleteDatabase('gograb-space');

// 2. Logout
// Click logout in UI or run:
window.location.href = '/auth/logout';

// 3. Login again
// Navigate to /auth/login

// 4. Fresh space will be created with correct slug

📝 Next Steps After Fix

Once space slug is correct:

  1. ✅ Test space creation with different names
  2. ✅ Test space updates (change name → slug regenerates)
  3. ✅ Test backend API persistence (space saved to MongoDB)
  4. ✅ Implement multi-space architecture (see MULTI-SPACE-ARCHITECTURE.md)
  5. ✅ Add space selector UI for users with multiple spaces

Status: ⏳ AWAITING USER ACTION

Next Action: Run clearCachedSpaceData() in console, then refresh! 🚀