feat: subdomain-aware SPA + SSR routing#234
Merged
Merged
Conversation
Mirrors RESERVED_SUBDOMAINS in packages/owletto-backend/src/index.ts at the DB layer so names like www/mcp/static/cdn/docs/mail can never be claimed as org slugs. `app` is intentionally NOT reserved because the auth org row uses slug='app'.
- buildPublicPageModel now accepts an optional subdomainOrg, synthesizes
the owner segment when the request path doesn't carry it, and strips
the prefix from bootstrap.path so the SPA hydration matcher aligns
with the post-replaceState pathname.
- Subdomain middleware 301-redirects HTML GETs that hit /{sub} or
/{sub}/... on the matching subdomain host so direct/bookmarked links
normalize. Scoped to text/html so API clients are unaffected.
Pairs with the SPA basepath rewrite in packages/owletto-web (#2 over there).
Pulls in lobu-ai/owletto#2: - feat(routing): make SPA subdomain-aware (TanStack Router basepath) - feat(connectors): sign-in CTA for unauthenticated public workspaces - chore(workspace-home): drop unused workspaceName prop
buremba
pushed a commit
that referenced
this pull request
Apr 23, 2026
Second pass on the 2-week PR review. Five more gaps closed: - gateway: unit tests for verifyOwnedAgentAccess covering owner, cross-tenant, cross-platform, agent-scoped, admin-bypass, unknown-agent, and external OAuth mismatches (#285 follow-up). Closes the test hole in the cross-tenant ownership guard. - owletto-backend: validate each CSP frame-ancestor entry against a strict host-source / scheme-source grammar before joining (#246 follow-up). Malformed env entries like `https:// lobu.ai` are now dropped instead of silently rendered into the directive. - owletto-backend: introduce normalizeHost() in utils/public-origin and use it from getSubdomainZone, extractSubdomainOrg, getCanonicalRedirectUrl, and the BetterAuth trustedOrigins wiring (#234/#224/#214 follow-up). Unifies the ad-hoc .toLowerCase()/.replace() patterns and adds IDN→punycode so `müller.lobu.ai` matches the ASCII zone configured in env. - owletto-backend: redact member emails that surface via template_data and tab template_data in resolve_path, not only on the single resolved entity (#309 follow-up). A dashboard data source that enumerates $member entities no longer leaks emails to non-admin callers. New utils/member-redaction helper plus unit coverage. - owletto-backend: treat #311 as already closed — ToolContext.memberRole is `string | null` (required, not optional), so TypeScript already catches future literal omissions at construction.
buremba
pushed a commit
that referenced
this pull request
Apr 23, 2026
Second pass on the 2-week PR review. Five more gaps closed: - gateway: unit tests for verifyOwnedAgentAccess covering owner, cross-tenant, cross-platform, agent-scoped, admin-bypass, unknown-agent, and external OAuth mismatches (#285 follow-up). Closes the test hole in the cross-tenant ownership guard. - owletto-backend: validate each CSP frame-ancestor entry against a strict host-source / scheme-source grammar before joining (#246 follow-up). Malformed env entries like `https:// lobu.ai` are now dropped instead of silently rendered into the directive. - owletto-backend: introduce normalizeHost() in utils/public-origin and use it from getSubdomainZone, extractSubdomainOrg, getCanonicalRedirectUrl, and the BetterAuth trustedOrigins wiring (#234/#224/#214 follow-up). Unifies the ad-hoc .toLowerCase()/.replace() patterns and adds IDN→punycode so `müller.lobu.ai` matches the ASCII zone configured in env. - owletto-backend: redact member emails that surface via template_data and tab template_data in resolve_path, not only on the single resolved entity (#309 follow-up). A dashboard data source that enumerates $member entities no longer leaks emails to non-admin callers. New utils/member-redaction helper plus unit coverage. - owletto-backend: treat #311 as already closed — ToolContext.memberRole is `string | null` (required, not optional), so TypeScript already catches future literal omissions at construction.
buremba
added a commit
that referenced
this pull request
Apr 23, 2026
…instr guard, MCP join rate-limit) (#325) * fix: address gaps found in post-merge review of last 2 weeks of PRs Follow-ups from an aggregated teammate review of 128 PRs merged between 2026-04-09 and 2026-04-23. Five concrete gaps patched: - worker: constrain UploadUserFile to the workspace root (#203 follow-up). path.join allowed `../` and absolute paths to escape the workspace. Now resolves and rejects anything outside workspaceDir when one is set. - core: flip Sentry sendDefaultPii to false (#172 follow-up). User content and identifiers flow through this stack; the schema has no scrubbing so PII-by-default was unsafe. - gateway: make SlackInstructionProvider extend BaseInstructionProvider (#269 follow-up). Sibling Skills/Network providers are wrapped in a try/catch that returns "" on error; Slack was bypassing it and would crash session-context assembly if listConnections threw. - owletto-backend: rate-limit the join_organization MCP tool to match the REST endpoint (#296 follow-up). Keyed on userId since MCP calls don't carry a client IP. Skipped one reviewer finding: removing the process.env fallback for API keys at worker.ts:1099/1109 (the inconsistency with #225 base-URL code). Embedded/dev workers depend on that fallback since credentialStore is only populated from gateway-supplied session context. * fix: address remaining gaps from post-merge review Second pass on the 2-week PR review. Five more gaps closed: - gateway: unit tests for verifyOwnedAgentAccess covering owner, cross-tenant, cross-platform, agent-scoped, admin-bypass, unknown-agent, and external OAuth mismatches (#285 follow-up). Closes the test hole in the cross-tenant ownership guard. - owletto-backend: validate each CSP frame-ancestor entry against a strict host-source / scheme-source grammar before joining (#246 follow-up). Malformed env entries like `https:// lobu.ai` are now dropped instead of silently rendered into the directive. - owletto-backend: introduce normalizeHost() in utils/public-origin and use it from getSubdomainZone, extractSubdomainOrg, getCanonicalRedirectUrl, and the BetterAuth trustedOrigins wiring (#234/#224/#214 follow-up). Unifies the ad-hoc .toLowerCase()/.replace() patterns and adds IDN→punycode so `müller.lobu.ai` matches the ASCII zone configured in env. - owletto-backend: redact member emails that surface via template_data and tab template_data in resolve_path, not only on the single resolved entity (#309 follow-up). A dashboard data source that enumerates $member entities no longer leaks emails to non-admin callers. New utils/member-redaction helper plus unit coverage. - owletto-backend: treat #311 as already closed — ToolContext.memberRole is `string | null` (required, not optional), so TypeScript already catches future literal omissions at construction. --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make the Lobu SPA + SSR treat the per-org subdomain (
{org}.lobu.ai) as the owner context so redundant/{org}prefixes disappear from generated links and direct URLs.buildPublicPageModelacceptssubdomainOrg, synthesizes the owner segment when the path doesn't carry one, and strips it frombootstrap.pathso SPA hydration matches. Subdomain middleware 301-redirects HTML GETs that hit/{sub}or/{sub}/...on the matching subdomain (scoped totext/htmlso API clients aren't affected).www,mcp,static,assets,cdn,docs,mail) — mirrorsRESERVED_SUBDOMAINSinpackages/owletto-backend/src/index.tsat the DB layer.appis intentionally not reserved (auth org row usesslug='app').basepath, boot URL canonicalization,useOrgContextsubdomain preference, plus a connector sign-in CTA and workspace-home prop cleanup.After this lands:
delivery.lobu.ai/→ delivery workspace root (SSR + SPA)delivery.lobu.ai/watchers→ delivery watchers (SPA)delivery.lobu.ai/delivery/...→ 301 todelivery.lobu.ai/...app.lobu.ai/delivery/...→ unchanged (path form on canonical host)Test plan
bun run typecheck(repo) — cleancd packages/owletto-web && bun run build— SPA bundle buildsbun x vitest run packages/owletto-backend/src/utils/__tests__/public-origin.test.ts— 18/18 passbun x vitest run packages/owletto-web/src/lib/subdomain.test.ts— 8/8 passcurl -I https://delivery.lobu.ai/deliveryreturns 301 tohttps://delivery.lobu.ai/https://delivery.lobu.ai/renders the delivery workspace; sidebar links keep the URL bar ondelivery.lobu.ai/<page>(no/deliveryprefix)https://app.lobu.ai/delivery/connectorscontinues to render (path form unaffected)