Skip to content

Event Routes Registered With Double Prefix — Production Endpoints Broken #224

@Ridanshi

Description

@Ridanshi

Summary

Event routes are registered with a duplicated /api/events prefix, causing all production event endpoints to resolve to incorrect paths.

As a result, event APIs become unreachable at their documented routes in production environments.


Affected Files

  • apps/backend/src/routes/event.ts
  • apps/backend/src/app.ts

Root Cause

The route plugin is registered with:

await app.register(eventRoutes, {
  prefix: '/api/events'
});

However, routes inside event.ts already define full absolute paths:

app.post('/api/events', ...)
app.get('/api/events/:slug', ...)

Fastify concatenates prefixes during registration, producing routes like:

/api/events/api/events
/api/events/api/events/:slug

instead of:

/api/events
/api/events/:slug

Why This Is Difficult To Detect

Unit tests register the plugin directly without the production prefix:

app.register(eventRoutes)

which makes tests pass successfully while production routing remains broken.

This creates a production-only failure masked by test configuration.


Impact

All event APIs become unreachable through their expected endpoints.

Affected functionality includes:

  • event creation,
  • event retrieval,
  • attendee management,
  • join/leave flows,
  • attendee listing.

This silently breaks the entire event subsystem in production deployments.


Reproduction

Attempt to access:

GET /api/events/some-event

Expected:

200 OK

Actual:

404 Not Found

Working route becomes:

GET /api/events/api/events/some-event

which is unintended and undocumented.


Proposed Fix

Remove hardcoded /api/events prefixes from route definitions inside event.ts.

Use relative plugin paths instead:

app.post('/')
app.get('/:slug')
app.post('/:slug/join')

This aligns the route structure with the plugin registration pattern already used elsewhere in the codebase.


Acceptance Criteria

  • Event routes resolve correctly under /api/events/*
  • No duplicated route prefixes remain
  • Existing tests continue passing
  • Add integration coverage validating production route registration

Severity

High

Entire production event functionality becomes inaccessible due to route registration misconfiguration.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions