feat: add subdomain-based site context with SSR resolution

Resolve the active site from the request Host header on the server and
expose it through a SiteContext provider so the app can vary rendering
per subdomain. Serialize the resolved site into the document shell
(data-site attribute + window.__SITE__) so client hydration matches the
server render. Add host-based Vercel rewrites mapping each subdomain to
its site root, and include unit tests for the site resolution logic.
This commit is contained in:
2026-07-23 09:18:55 -04:00
parent 0385090f32
commit 92890ce259
7 changed files with 552 additions and 35 deletions

View File

@@ -15,6 +15,7 @@ import ErrorBoundaryFallback from "./components/ErrorBoundaryFallback";
import { BarsProvider, useBars } from "./context/bars";
import { DarkModeProvider } from "./context/darkMode";
import { AuthProvider } from "./context/auth";
import { SiteProvider } from "./context/SiteContext";
import { createWindowWidth, isMobile } from "~/lib/resize-utils";
import { MOBILE_CONFIG } from "./config";
import CustomScrollbar from "./components/CustomScrollbar";
@@ -203,17 +204,19 @@ export default function App() {
)}
>
<DarkModeProvider>
<BarsProvider>
<Router
root={(props) => (
<AuthProvider>
<AppLayout>{props.children}</AppLayout>
</AuthProvider>
)}
>
<FileRoutes />
</Router>
</BarsProvider>
<SiteProvider>
<BarsProvider>
<Router
root={(props) => (
<AuthProvider>
<AppLayout>{props.children}</AppLayout>
</AuthProvider>
)}
>
<FileRoutes />
</Router>
</BarsProvider>
</SiteProvider>
</DarkModeProvider>
</ErrorBoundary>
</MetaProvider>