diff --git a/server/index.ts b/server/index.ts index d55dc3d..4d607eb 100644 --- a/server/index.ts +++ b/server/index.ts @@ -96,29 +96,6 @@ const PORT = Number(process.env.PORT) || 3000; const INTERNAL_API_KEY = process.env.INTERNAL_API_KEY || ""; const DIST_DIR = resolve(import.meta.dir, "../dist"); -// ── Standalone landing page proxy cache ── -const landingCache = new Map(); -const LANDING_TTL = 5 * 60 * 1000; // 5 minutes - -async function fetchStandaloneLanding(domain: string): Promise { - const cached = landingCache.get(domain); - if (cached && Date.now() - cached.at < LANDING_TTL) return cached.html; - - try { - const resp = await fetch(`https://${domain}/`, { - headers: { "Accept": "text/html" }, - redirect: "follow", - }); - if (!resp.ok) return null; - let html = await resp.text(); - // Inject so relative assets (CSS, JS, images) resolve to the standalone domain - html = html.replace(/]*)>/i, `\n`); - landingCache.set(domain, { html, at: Date.now() }); - return html; - } catch { - return null; - } -} // ── Hono app ── const app = new Hono(); @@ -802,7 +779,7 @@ const server = Bun.serve({ } // ── Bare-domain module routes: rspace.online/{moduleId} ── - // Exact module path → proxy the standalone domain's landing page. + // Exact module path → embed standalone domain in iframe (avoids CORS). // Sub-paths (API, assets) → rewrite to /demo/{moduleId}/... for backward compat. if (!subdomain && hostClean.includes("rspace.online")) { const pathSegments = url.pathname.split("/").filter(Boolean); @@ -810,18 +787,8 @@ const server = Bun.serve({ const firstSegment = pathSegments[0]; const knownModuleIds = new Set(getAllModules().map((m) => m.id)); if (knownModuleIds.has(firstSegment)) { - // Exact module path → proxy from standalone domain + // Exact module path → landing page with iframe embed if (pathSegments.length === 1) { - const mod = getAllModules().find((m) => m.id === firstSegment); - if (mod?.standaloneDomain) { - const html = await fetchStandaloneLanding(mod.standaloneDomain); - if (html) { - return new Response(html, { - headers: { "Content-Type": "text/html; charset=utf-8" }, - }); - } - } - // Fallback: generated landing page (no standalone domain or fetch failed) const modInfo = getModuleInfoList().find((m) => m.id === firstSegment); if (modInfo) { return new Response( diff --git a/server/shell.ts b/server/shell.ts index e3b808f..bd634b0 100644 --- a/server/shell.ts +++ b/server/shell.ts @@ -45,10 +45,7 @@ export function renderShell(opts: ShellOptions): string { } = opts; const moduleListJSON = JSON.stringify(modules); - const currentMod = modules.find((m) => m.id === moduleId); - const shellDemoUrl = currentMod?.standaloneDomain - ? `https://${escapeAttr(currentMod.standaloneDomain)}` - : `https://demo.rspace.online/${escapeAttr(moduleId)}`; + const shellDemoUrl = `https://rspace.online/${escapeAttr(moduleId)}`; return ` @@ -428,35 +425,54 @@ export interface ModuleLandingOptions { export function renderModuleLanding(opts: ModuleLandingOptions): string { const { module: mod, modules, theme = "dark" } = opts; const moduleListJSON = JSON.stringify(modules); - // Prefer standalone domain for demo (better styling, more updated features) - const demoUrl = mod.standaloneDomain - ? `https://${mod.standaloneDomain}` - : `https://demo.rspace.online/${mod.id}`; - const standaloneLinkHtml = mod.standaloneDomain - ? `Also available inside rSpace demo ↗` - : ""; - - let feedsHtml = ""; - if (mod.feeds && mod.feeds.length > 0) { - feedsHtml = ` -
-

Capabilities

-
- ${mod.feeds - .map( - (f) => ` -
-
${escapeHtml(f.name)}
-
${escapeHtml(f.description)}
- ${escapeHtml(f.kind)} -
`, - ) - .join("")} -
-
`; + // Modules with a standalone domain: embed it in a full-page iframe + if (mod.standaloneDomain) { + const embedUrl = `https://${escapeAttr(mod.standaloneDomain)}`; + return ` + + + + + + ${escapeHtml(mod.name)} — rSpace + + + + + +
+
+ +
+
+ +
+
+ +
+ + +`; } + // Modules without a standalone domain: simple generated landing page + const demoUrl = `https://demo.rspace.online/${mod.id}`; + return ` @@ -479,7 +495,6 @@ export function renderModuleLanding(opts: ModuleLandingOptions): string { -
${mod.icon} @@ -489,21 +504,14 @@ export function renderModuleLanding(opts: ModuleLandingOptions): string { Try Demo Create a Space
- ${standaloneLinkHtml}
- - ${feedsHtml} - -