From c3bb496a98cdeaf9a6112fc0feb4e09e22ef62f9 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Fri, 13 Feb 2026 00:05:54 +0100 Subject: [PATCH] fix(routes): add explicit redirects for /merchants and /admin without trailing slash 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 --- main.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/main.py b/main.py index d8b80598..641567dd 100644 --- a/main.py +++ b/main.py @@ -332,6 +332,24 @@ logger.info("=" * 80) logger.info("ROUTE REGISTRATION (AUTO-DISCOVERY)") 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.) # =============================================================================