fix: getApiBase() across all 16 rApp modules for subdomain routing

All modules had getApiBase() matching wrong module names (e.g. /vote
instead of /rvote) and requiring /{space}/ prefix in the URL path.
On subdomains like jeff.rspace.online, the browser URL is /rfunds/...
not /jeff/rfunds/..., so the regex never matched.

New pattern: /^(\/[^/]+)?\/rmodule/ handles both:
- Subdomain: /rfunds/... → base = /rfunds
- Direct: /demo/rfunds/... → base = /demo/rfunds

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-03-02 21:01:06 -08:00
parent cb5952c770
commit b6ddd4a833
16 changed files with 41 additions and 43 deletions

View File

@ -354,8 +354,8 @@ class FolkCalendarView extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
// When on the rcal page directly, extract from URL // When on the rcal page directly, extract from URL
const match = window.location.pathname.match(/^\/([^/]+)\/rcal/); const match = window.location.pathname.match(/^(\/[^/]+)?\/rcal/);
if (match) return `/${match[1]}/rcal`; if (match) return match[0];
// When embedded as a canvas shape, use the space attribute // When embedded as a canvas shape, use the space attribute
if (this.space) return `/${this.space}/rcal`; if (this.space) return `/${this.space}/rcal`;
return ""; return "";

View File

@ -184,8 +184,8 @@ class FolkCartShop extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const parts = path.split("/").filter(Boolean); const match = path.match(/^(\/[^/]+)?\/rcart/);
return parts.length >= 2 ? `/${parts[0]}/cart` : "/demo/cart"; return match ? match[0] : "/rcart";
} }
private async loadData() { private async loadData() {

View File

@ -43,8 +43,8 @@ class FolkChoicesDashboard extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const parts = path.split("/").filter(Boolean); const match = path.match(/^(\/[^/]+)?\/rchoices/);
return parts.length >= 2 ? `/${parts[0]}/choices` : "/demo/choices"; return match ? match[0] : "/rchoices";
} }
private async loadChoices() { private async loadChoices() {

View File

@ -161,8 +161,8 @@ class FolkFileBrowser extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const match = path.match(/^\/([^/]+)\/files/); const match = path.match(/^(\/[^/]+)?\/rfiles/);
return match ? `/${match[1]}/files` : ""; return match ? match[0] : "";
} }
private formatSize(bytes: number): string { private formatSize(bytes: number): string {

View File

@ -43,8 +43,8 @@ class FolkForumDashboard extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const match = path.match(/^\/([^/]+)\/forum/); const match = path.match(/^(\/[^/]+)?\/rforum/);
return match ? `/${match[1]}/forum` : ""; return match ? match[0] : "";
} }
private getAuthHeaders(): Record<string, string> { private getAuthHeaders(): Record<string, string> {

View File

@ -132,8 +132,9 @@ class FolkFundsApp extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const match = path.match(/^\/([^/]+)\/funds/); // Subdomain: /rfunds/... or Direct: /{space}/rfunds/...
return match ? `/${match[1]}/funds` : ""; const match = path.match(/^(\/[^/]+)?\/rfunds/);
return match ? `${match[0]}` : "";
} }
private async loadFlows() { private async loadFlows() {
@ -221,7 +222,7 @@ class FolkFundsApp extends HTMLElement {
// ─── Landing page ────────────────────────────────────── // ─── Landing page ──────────────────────────────────────
private renderLanding(): string { private renderLanding(): string {
const demoUrl = this.getApiBase() ? `${this.getApiBase().replace(/\/funds$/, "")}/funds/demo` : "/demo"; const demoUrl = this.getApiBase() ? `${this.getApiBase()}/demo` : "/rfunds/demo";
const authed = isAuthenticated(); const authed = isAuthenticated();
const username = getUsername(); const username = getUsername();
@ -325,8 +326,8 @@ class FolkFundsApp extends HTMLElement {
private renderFlowCard(f: FlowSummary): string { private renderFlowCard(f: FlowSummary): string {
const detailUrl = this.getApiBase() const detailUrl = this.getApiBase()
? `${this.getApiBase().replace(/\/funds$/, "")}/funds/flow/${encodeURIComponent(f.id)}` ? `${this.getApiBase()}/flow/${encodeURIComponent(f.id)}`
: `/flow/${encodeURIComponent(f.id)}`; : `/rfunds/flow/${encodeURIComponent(f.id)}`;
const value = f.totalValue != null ? `$${Math.floor(f.totalValue).toLocaleString()}` : ""; const value = f.totalValue != null ? `$${Math.floor(f.totalValue).toLocaleString()}` : "";
return ` return `
@ -345,8 +346,8 @@ class FolkFundsApp extends HTMLElement {
private renderDetail(): string { private renderDetail(): string {
const backUrl = this.getApiBase() const backUrl = this.getApiBase()
? `${this.getApiBase().replace(/\/funds$/, "")}/funds/` ? `${this.getApiBase()}/`
: "/"; : "/rfunds/";
return ` return `
<div class="funds-detail"> <div class="funds-detail">
@ -2268,8 +2269,8 @@ class FolkFundsApp extends HTMLElement {
// Navigate to the new flow // Navigate to the new flow
if (flowId) { if (flowId) {
const detailUrl = this.getApiBase() const detailUrl = this.getApiBase()
? `${this.getApiBase().replace(/\/funds$/, "")}/funds/flow/${encodeURIComponent(flowId)}` ? `${this.getApiBase()}/flow/${encodeURIComponent(flowId)}`
: `/flow/${encodeURIComponent(flowId)}`; : `/rfunds/flow/${encodeURIComponent(flowId)}`;
window.location.href = detailUrl; window.location.href = detailUrl;
return; return;
} }

View File

@ -774,8 +774,8 @@ class FolkMapViewer extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const match = path.match(/^\/([^/]+)\/maps/); const match = path.match(/^(\/[^/]+)?\/rmaps/);
return match ? `/${match[1]}/maps` : ""; return match ? match[0] : "";
} }
private async checkSyncHealth() { private async checkSyncHealth() {

View File

@ -107,8 +107,8 @@ class FolkGraphViewer extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const match = path.match(/^\/([^/]+)\/network/); const match = path.match(/^(\/[^/]+)?\/rnetwork/);
return match ? `/${match[1]}/network` : ""; return match ? match[0] : "";
} }
private async loadData() { private async loadData() {

View File

@ -633,8 +633,8 @@ Gear: EUR 400 (10%)</code></pre><p><em>Maya is tracking expenses in rF
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const match = path.match(/^\/([^/]+)\/notes/); const match = path.match(/^(\/[^/]+)?\/rnotes/);
return match ? `/${match[1]}/notes` : ""; return match ? match[0] : "";
} }
private async loadNotebooks() { private async loadNotebooks() {

View File

@ -113,12 +113,12 @@ class FolkPhotoGallery extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const match = path.match(/^\/([^/]+)\/rphotos/); const match = path.match(/^(\/[^/]+)?\/rphotos/);
return match ? `/${match[1]}/rphotos` : ""; return match ? match[0] : "";
} }
private getImmichUrl(): string { private getImmichUrl(): string {
return `/${this.space}/rphotos/album`; return `${this.getApiBase()}/album`;
} }
private async loadGallery() { private async loadGallery() {

View File

@ -184,8 +184,8 @@ class FolkSwagDesigner extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const parts = path.split("/").filter(Boolean); const match = path.match(/^(\/[^/]+)?\/rswag/);
return parts.length >= 2 ? `/${parts[0]}/swag` : "/demo/swag"; return match ? match[0] : "/rswag";
} }
private getDemoProduct(): DemoProduct { private getDemoProduct(): DemoProduct {

View File

@ -42,11 +42,8 @@ class FolkRoutePlanner extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const parts = path.split("/").filter(Boolean); const match = path.match(/^(\/[^/]+)?\/rtrips/);
if (parts.length >= 2 && parts[1] === "trips") { return match ? match[0] : "/rtrips";
return `/${parts[0]}/trips`;
}
return "/demo/trips";
} }
private async fetchRoute(input: RouteInput): Promise<FittedRoute> { private async fetchRoute(input: RouteInput): Promise<FittedRoute> {

View File

@ -292,8 +292,8 @@ class FolkTripsPlanner extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const match = path.match(/^\/([^/]+)\/trips/); const match = path.match(/^(\/[^/]+)?\/rtrips/);
return match ? `/${match[1]}/trips` : ""; return match ? match[0] : "";
} }
private async loadTrips() { private async loadTrips() {

View File

@ -133,8 +133,8 @@ class FolkVoteDashboard extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const match = path.match(/^\/([^/]+)\/vote/); const match = path.match(/^(\/[^/]+)?\/rvote/);
return match ? `/${match[1]}/vote` : ""; return match ? match[0] : "";
} }
private async loadSpaces() { private async loadSpaces() {

View File

@ -86,8 +86,8 @@ class FolkWalletViewer extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const match = path.match(/^\/([^/]+)\/wallet/); const match = path.match(/^(\/[^/]+)?\/rwallet/);
return match ? `/${match[1]}/wallet` : ""; return match ? match[0] : "";
} }
private async detectChains() { private async detectChains() {

View File

@ -56,8 +56,8 @@ class FolkWorkBoard extends HTMLElement {
private getApiBase(): string { private getApiBase(): string {
const path = window.location.pathname; const path = window.location.pathname;
const match = path.match(/^\/([^/]+)\/work/); const match = path.match(/^(\/[^/]+)?\/rwork/);
return match ? `/${match[1]}/work` : ""; return match ? match[0] : "";
} }
private async loadWorkspaces() { private async loadWorkspaces() {