From 16edbdf54469387701cff166a8dae68fe20e067e Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Tue, 24 Feb 2026 23:18:17 -0800 Subject: [PATCH] fix: space links use subdomain URLs instead of rspace.online path Space links now go to . (e.g., myspace.rfunds.online) instead of rspace.online/. Domain derived from window.location when not explicitly provided. Co-Authored-By: Claude Opus 4.6 --- src/components/SpaceSwitcher.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/SpaceSwitcher.tsx b/src/components/SpaceSwitcher.tsx index 33db21a..f5a9450 100644 --- a/src/components/SpaceSwitcher.tsx +++ b/src/components/SpaceSwitcher.tsx @@ -9,13 +9,23 @@ interface SpaceInfo { role?: string; } -export function SpaceSwitcher() { +interface SpaceSwitcherProps { + /** Current app domain, e.g. 'rfunds.online'. Space links become . */ + domain?: string; +} + +export function SpaceSwitcher({ domain }: SpaceSwitcherProps) { const [open, setOpen] = useState(false); const [spaces, setSpaces] = useState([]); const [loaded, setLoaded] = useState(false); const [isAuthenticated, setIsAuthenticated] = useState(false); const ref = useRef(null); + // Derive domain from window.location if not provided + const appDomain = domain || (typeof window !== 'undefined' + ? window.location.hostname.split('.').slice(-2).join('.') + : 'rspace.online'); + useEffect(() => { function handleClick(e: MouseEvent) { if (ref.current && !ref.current.contains(e.target as Node)) { @@ -58,6 +68,9 @@ export function SpaceSwitcher() { } }; + /** Build URL for a space: . */ + const spaceUrl = (slug: string) => `https://${slug}.${appDomain}`; + const mySpaces = spaces.filter((s) => s.role); const publicSpaces = spaces.filter((s) => !s.role); @@ -99,7 +112,7 @@ export function SpaceSwitcher() { {mySpaces.map((s) => ( setOpen(false)} > @@ -124,7 +137,7 @@ export function SpaceSwitcher() { {publicSpaces.map((s) => ( setOpen(false)} >