Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 2.27 KB

File metadata and controls

64 lines (47 loc) · 2.27 KB

🔧 API Routing Fix - URL Format Clarification

❌ The Problem

User tried to access: https://bmad-lead-gen-agent.vercel.app/api/preview/eb0tzt77 Error: 404: NOT_FOUND - DNS_HOSTNAME_RESOLVED_PRIVATE

🎯 The Solution

Correct URL Format:

  • ✅ Frontend Preview Pages: /preview/{id} (no /api/)
  • ✅ Backend API Endpoints: /api/previews/{id} (with /api/)

Fixed URL:

  • ❌ Wrong: https://bmad-lead-gen-agent.vercel.app/api/preview/eb0tzt77
  • ✅ Correct: https://bmad-lead-gen-agent.vercel.app/preview/eb0tzt77

🛠️ Configuration Updates

Updated vercel.json:

  • Specific API route mappings instead of wildcard
  • Prevents confusion between frontend and backend routes
  • /api/previews/* → backend API
  • /preview/* → frontend pages

Updated next.config.js:

  • Explicit API route definitions
  • Cleaner separation of concerns
  • Better error handling

📋 URL Structure Guide

Frontend Routes (Vercel):

  • Main app: https://bmad-lead-gen-agent.vercel.app/
  • Preview pages: https://bmad-lead-gen-agent.vercel.app/preview/{id}
  • Example: https://bmad-lead-gen-agent.vercel.app/preview/eb0tzt77

Backend API Routes (Railway via Vercel proxy):

  • Get preview data: https://bmad-lead-gen-agent.vercel.app/api/previews/{id}
  • Get preview HTML: https://bmad-lead-gen-agent.vercel.app/api/previews/{id}/html
  • List previews: https://bmad-lead-gen-agent.vercel.app/api/previews

Direct Backend Access (Railway):

  • All endpoints: https://bmad-backend-production.up.railway.app/api/previews/*

🧪 Testing the Fix

Test the correct preview URL:

  1. Visit: https://bmad-lead-gen-agent.vercel.app/preview/eb0tzt77
  2. Should load the preview page with professional UI
  3. If preview doesn't exist, will show "Preview not found" message

Test API access:

  1. API data: https://bmad-lead-gen-agent.vercel.app/api/previews/eb0tzt77
  2. Should return JSON metadata about the preview
  3. If backend not ready, will show appropriate error

🚀 Next Steps

  1. Commit the routing fixes
  2. Deploy updated configuration
  3. Test the corrected URL format
  4. Verify end-to-end functionality

The issue was a URL format confusion - the fix ensures proper routing separation between frontend preview pages and backend API endpoints.