From 030d69b29f80822ad7a5a51e18e64d91427021a9 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Wed, 15 Apr 2026 16:09:32 -0400 Subject: [PATCH] fix(routing): redirect module-as-subdomain to demo instead of treating as space rcred.rspace.online was being treated as a space slug, triggering auto-provision + redirect to /rspace. Now any subdomain matching a known module ID (rcred, rvote, etc.) redirects to demo.rspace.online/{moduleId}. Co-Authored-By: Claude Opus 4.6 --- server/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/index.ts b/server/index.ts index 68eca54a..6a66099f 100644 --- a/server/index.ts +++ b/server/index.ts @@ -4070,6 +4070,14 @@ const server = Bun.serve({ // ── Subdomain routing: {space}.rspace.online/{moduleId}/... ── if (subdomain) { + // ── Guard: module IDs are not space slugs ── + // Redirect rcred.rspace.online → demo.rspace.online/rcred (not a space) + const allModuleIds = new Set(getAllModules().map(m => m.id)); + if (allModuleIds.has(subdomain.toLowerCase())) { + const pathSuffix = url.pathname === "/" ? "" : url.pathname; + return Response.redirect(`${proto}//demo.rspace.online/${subdomain}${pathSuffix}${url.search}`, 302); + } + // ── Auto-provision personal space on first visit ── // Fast path: communityExists is an in-memory Map check for cached spaces. if (!(await communityExists(subdomain))) {