FDA

Project 1 - Admin Panel

Admin Panel - Marketing API

The Admin Panel exposes a public API (no auth) so the marketing homepage can show courses, categories, and blogs. Only published content is returned.

Endpoints

MethodEndpointDescription
GET/api/public/coursesAll published courses (marketing-friendly format)
GET/api/public/courses/[id]Single published course (e.g. with modules/chapters)
GET/api/public/categoriesAll course categories
GET/api/public/blogsAll published blogs
GET/api/public/blogs/categoriesAll blog categories

Usage from marketing site

Base URL is the Admin Panel origin (e.g. https://learn.fda.org.in or http://localhost:3000). Set in the marketing app:

NEXT_PUBLIC_API_BASE_URL=https://learn.fda.org.in

Example (Next.js server or client):

const base = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:3000'
const res = await fetch(`${base}/api/public/courses`)
const courses = await res.json()

Course response shape (typical)

The public courses API often returns (or is adapted to) a structure like:

  • id, slug, title, subtitle, description, thumbnail, video_url
  • instructor: { id, name }
  • price, duration, level, format
  • learningOutcomes[], prerequisites[], categories[]
  • createdAt, updatedAt

Slugs are usually derived from the title for URL-friendly links. Missing fields may get defaults (e.g. price 0, level "Beginner"). See the admin-panel’s MARKETING_API_INTEGRATION.md and src/lib/marketing/adapter.ts for exact mapping.

CORS

If the marketing site is on a different origin, the Admin Panel may need CORS headers for /api/public/*:

// next.config.mjs (admin-panel)
async headers() {
  return [
    {
      source: '/api/public/:path*',
      headers: [
        { key: 'Access-Control-Allow-Origin', value: '*' },
        { key: 'Access-Control-Allow-Methods', value: 'GET' },
        { key: 'Access-Control-Allow-Headers', value: 'Content-Type' },
      ],
    },
  ]
}

Tighten Access-Control-Allow-Origin in production if needed.

Testing

curl http://localhost:3000/api/public/courses
curl http://localhost:3000/api/public/categories
curl http://localhost:3000/api/public/blogs

Only courses/blogs with status Published appear. The marketing homepage uses these endpoints and can fall back to static data if the API is unavailable (see Marketing API Integration).

Previous
Chat system