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