Bugfix: Why did /api/api/ double prefix appear in backend-api Swagge...

Documentation for Sessions

🐛 Bugfix: Why did /api/api/ double prefix appear in backend-api Swagge...

Date: 2026-02-20
Time: 19:28:31 UTC
Session: gspace1-129.3
Agent: backend
Confidence: 100%
Status: ✅ Documented


📋 Decision Context

Question:

Why did /api/api/ double prefix appear in backend-api Swagger and how was it fixed?

Task: Fix /api/api/ double prefix bug in backend-api


🎯 Decision Made

Chosen:

Removed redundant 'api/' from 6 @Controller() decorators + 1 code-gen template in backend-api. The global prefix setGlobalPrefix('api') in main.ts already adds /api to all routes — controllers must use paths relative to it (e.g. @Controller('spaces/:spaceId/files'), NOT @Controller('api/spaces/:spaceId/files')).

Options Considered:


💭 Reasoning

NestJS setGlobalPrefix('api') prepends /api to every registered route. Controllers that also included 'api/' in their @Controller() path produced /api/api/... routes visible in Swagger. This made endpoints unreachable via the expected /api/... URLs. The Vitto backend-api-client was silently 404ing on /api/users/hierarchy because the actual route was /api/api/users/hierarchy. No callers had adapted to the double prefix — all used the correct single-prefix pattern. This exact bug was previously fixed in Session 31 for global-modules but was re-introduced in Session 52.2 when new controllers were added by someone unaware of setGlobalPrefix.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation