Skip to content

MEDIUM: /api returns HTML docs page instead of JSON for unmatched routes #90

Description

@Inkcha

Description

The /api route (apps/web/app/api/page.tsx) renders an HTML documentation page instead of returning a JSON 404 for unmatched API routes. When clients call undefined API endpoints, Next.js serves this 28KB HTML page instead of a proper JSON error.

Location

apps/web/app/api/page.tsx — This creates a catch-all page.tsx at /api

Impact

API consumers expecting JSON responses get hard-to-parse HTML back when hitting:

  • /api (should return JSON description of available endpoints or 404)
  • Any unmatched /api/* route

This breaks client error handling and makes the API less interoperable.

Suggested Fix

Either:

  1. Move docs to a non-API path like /docs/api
  2. Return a JSON response with available endpoints from the /api route
  3. Use Next.js not-found.tsx at the api level for a JSON 404

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions