fix(routes): add explicit redirects for /merchants and /admin without trailing slash
Some checks failed
CI / ruff (push) Failing after 8s
CI / pytest (push) Failing after 46s
CI / architecture (push) Failing after 10s
CI / dependency-scanning (push) Successful in 39s
CI / audit (push) Successful in 14s
CI / docs (push) Has been skipped

The CMS /{slug} catch-all at root level intercepts these paths before
FastAPI can redirect to the prefixed routers, causing a 404.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 00:05:54 +01:00
parent 779de02f97
commit c3bb496a98

18
main.py
View File

@@ -332,6 +332,24 @@ logger.info("=" * 80)
logger.info("ROUTE REGISTRATION (AUTO-DISCOVERY)") logger.info("ROUTE REGISTRATION (AUTO-DISCOVERY)")
logger.info("=" * 80) logger.info("=" * 80)
# =============================================================================
# EXPLICIT REDIRECTS for paths that clash with the CMS /{slug} catch-all
# =============================================================================
# The CMS catch-all /{slug} at root level intercepts /merchants, /admin, etc.
# (without trailing slash) before FastAPI can redirect to the prefixed routers.
# These explicit routes ensure clean URLs work.
@app.get("/merchants", include_in_schema=False)
async def merchants_redirect():
return RedirectResponse(url="/merchants/", status_code=301)
@app.get("/admin", include_in_schema=False)
async def admin_redirect():
return RedirectResponse(url="/admin/", status_code=301)
# ============================================================================= # =============================================================================
# PLATFORM PAGES (Marketing pages - homepage, pricing, signup, etc.) # PLATFORM PAGES (Marketing pages - homepage, pricing, signup, etc.)
# ============================================================================= # =============================================================================