fix: rspace.online/r* now renders same shell as r*.online

Instead of serving a special iframe landing page, bare-domain module
paths now rewrite to /demo/{moduleId} — identical to standalone domains.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-02-27 12:37:05 -08:00
parent 5d19ad169c
commit 763f897c11
1 changed files with 4 additions and 18 deletions

View File

@ -63,7 +63,7 @@ import { dataModule } from "../modules/data/mod";
import { splatModule } from "../modules/splat/mod";
import { photosModule } from "../modules/photos/mod";
import { spaces } from "./spaces";
import { renderShell, renderModuleLanding } from "./shell";
import { renderShell } from "./shell";
import { syncServer } from "./sync-instance";
import { loadAllDocs } from "./local-first/doc-persistence";
@ -778,29 +778,15 @@ const server = Bun.serve<WSData>({
return app.fetch(rewrittenReq);
}
// ── Bare-domain module routes: rspace.online/{moduleId} ──
// Exact module path → embed standalone domain in iframe (avoids CORS).
// Sub-paths (API, assets) → rewrite to /demo/{moduleId}/... for backward compat.
// ── Bare-domain module routes: rspace.online/{moduleId}[/...] ──
// Rewrite to /demo/{moduleId}/... so the normal shell renders identically
// to how standalone domains (e.g. rtube.online) serve their content.
if (!subdomain && hostClean.includes("rspace.online")) {
const pathSegments = url.pathname.split("/").filter(Boolean);
if (pathSegments.length >= 1) {
const firstSegment = pathSegments[0];
const knownModuleIds = new Set(getAllModules().map((m) => m.id));
if (knownModuleIds.has(firstSegment)) {
// Exact module path → landing page with iframe embed
if (pathSegments.length === 1) {
const modInfo = getModuleInfoList().find((m) => m.id === firstSegment);
if (modInfo) {
return new Response(
renderModuleLanding({
module: modInfo,
modules: getModuleInfoList(),
}),
{ headers: { "Content-Type": "text/html; charset=utf-8" } },
);
}
}
// Sub-paths → rewrite to demo space
const rewrittenPath = `/demo${url.pathname}`;
const rewrittenUrl = new URL(rewrittenPath + url.search, `http://localhost:${PORT}`);
const rewrittenReq = new Request(rewrittenUrl, req);