Skip to content

fix: /api returns JSON 404 instead of HTML for unmatched routes - #96

Merged
ralyodio merged 1 commit into
profullstack:masterfrom
Inkcha:fix/api-json-404
Jul 31, 2026
Merged

fix: /api returns JSON 404 instead of HTML for unmatched routes#96
ralyodio merged 1 commit into
profullstack:masterfrom
Inkcha:fix/api-json-404

Conversation

@Inkcha

@Inkcha Inkcha commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Description

Previously, GET /api served an HTML documentation page. API consumers calling undefined endpoints received 28KB of HTML instead of a proper JSON error, breaking client error handling.

Changes

  • Moved API docs from /api to /api-docs (same content, new URL)
  • Created catch-all route at /api/[[...slug]] that returns JSON 404 for any unmatched API route
  • All working API routes are unchanged (they match before the catch-all)

Related

Addresses the MEDIUM issue reported in #90

Testing

  • GET /api -> {"error": "Not found. See /api-docs for API documentation."} (HTTP 404)
  • GET /api/v1/opinions -> still works
  • GET /api-docs -> still shows the docs page

The /api directory previously had a page.tsx that rendered an HTML
API documentation page at the /api URL. This caused API consumers
making requests to undefined endpoints to receive 28KB of HTML
instead of a proper JSON error response.

Changes:
- Moved API docs from /api to /api-docs
- Created catch-all route at /api/[[...slug]] returning JSON 404
- All previously working API routes remain unchanged
@ralyodio
ralyodio merged commit 68e2eb4 into profullstack:master Jul 31, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants