Skip to content

Fix client API paths: remove /v1 prefix to match server endpoints#5

Merged
sparck75 merged 2 commits intomainfrom
copilot/fix-aggregates-endpoint-json
Feb 14, 2026
Merged

Fix client API paths: remove /v1 prefix to match server endpoints#5
sparck75 merged 2 commits intomainfrom
copilot/fix-aggregates-endpoint-json

Conversation

Copy link
Contributor

Copilot AI commented Feb 14, 2026

Client was calling versioned /api/v1/* endpoints but server only serves /api/*, causing 404s and fallthrough to frontend catch-all route (returning HTML instead of JSON).

Changes

Updated src/client.ts - Removed /v1 prefix from all endpoint paths:

  • Events: /api/v1/events/api/events
  • Aggregates: /api/v1/aggregates/api/aggregates
  • Enrichment: /api/v1/aggregates/{id}/enrich/api/aggregates/{id}/enrich
  • Deliveries: /api/v1/deliveries/api/deliveries
  • Subscribers: /api/v1/subscribers/api/subscribers

Updated tests/client.test.ts - Modified test expectations to assert non-versioned paths.

Example

Before:

await client.aggregates.list();
// → GET /api/v1/aggregates (404, returns HTML)

After:

await client.aggregates.list();
// → GET /api/aggregates (200, returns JSON)
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix: Aggregates endpoint returns HTML instead of JSON</issue_title>
<issue_description># Issue 2: Fix aggregates endpoint returning HTML

Summary

The /api/aggregates endpoint returns HTML (the frontend app) instead of JSON, making it unusable for API clients.

Current Behavior

$ curl -H "Authorization: Bearer $API_KEY" https://webhook.alteriom.net/api/aggregates
<!doctype html>
<html lang="en">
...

Expected Behavior

{
  "aggregates": [...],
  "total": 123,
  "limit": 20,
  "offset": 0
}

Root Cause

Likely routing issue where /api/aggregates is falling through to the frontend catch-all route instead of hitting the API handler.

Reproduction

const res = await fetch('https://webhook.alteriom.net/api/aggregates', {
  headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
});
const data = await res.json(); // Error: Unexpected token '<'

Investigation Needed

  1. Check Express/Fastify route order (API routes must come before app.use('*', frontend))
  2. Verify aggregates route is registered: app.get('/api/aggregates', handler)
  3. Check if path is missing from router exports

Impact

  • Severity: High
  • Affected: All API clients trying to list aggregates
  • Workaround: None currently

Priority

Critical - Core API endpoint non-functional

Labels

bug, api, routing</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: sparck75 <14064405+sparck75@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix aggregates endpoint returning HTML instead of JSON Fix client API paths: remove /v1 prefix to match server endpoints Feb 14, 2026
Copilot AI requested a review from sparck75 February 14, 2026 04:21
@sparck75 sparck75 marked this pull request as ready for review February 14, 2026 05:23
@sparck75 sparck75 merged commit 5dd1f3b into main Feb 14, 2026
6 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.

Fix: Aggregates endpoint returns HTML instead of JSON

2 participants