fix(router): production share links were dead (ingress strips /r) + host-scoped keys + copyable link URLs#43
Merged
Conversation
…ere dead DO App Platform's ingress strips the matched /r prefix before forwarding (same as it strips /api), so in production the router received /<key>, matched no route, and returned Hono's default 404 — on EVERY hosted domain, platform and custom alike. The api component survives identical stripping because its routes are mounted prefix-less; the router's weren't. - Mount both shapes: /r/:slug/:linkKey + /r/:linkKey (dev, self-host proxies, direct hits) and /:slug/:linkKey + /:linkKey (stripped). /health is static and Hono prefers static over params. - Key-only lookups are now HOST-SCOPED on white-label custom domains (Host → Tenant.customDomain → tenant-bound Link query), so portal.brand.com/r/<key> resolves the right tenant's key and two tenants may share a key string. Unknown hosts keep the global single-tenant fallback. - Links page: share keys render as full copyable URLs matched to the context — /r/<slug>/<key> on the platform origin, /r/<key> on a custom domain, relative display on self-host (portal origin isn't guaranteed to serve /r). /branding + usePublicBrand expose tenantSlug for the custom-domain detection. Co-Authored-By: Claude Fable 5 <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.
Customer report (xispark):
affiliate.xispark.com/r/<key>404s. Investigation showed it's much bigger: the click router has been dead on every hosted domain — DO's ingress strips the matched/rprefix (exactly like/api), the router's routes expect the prefix, so every request fell through to Hono's default 404. Verified live on both the platform domain and the custom domain; the 404 body was Hono's default, not the router's own.Tenant.customDomain→ tenant-bound key query) —portal.brand.com/r/<key>resolves the right tenant and keys needn't be globally unique/r/<slug>/<key>; custom domain:/r/<key>; self-host keeps the relative display)No spec/infra change needed — code accepts what the ingress actually sends. Suites green: api 192/192, portal 12/12, router 3/3.
🤖 Generated with Claude Code