Expose whether a route isServerOnly so locale rewrites can avoid server-only routes #7397
jasongitmail
started this conversation in
Ideas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Feature Request
I’m using
rewrite.inputfor locale-prefixed routes.Desired Behavior
/es/contact-> internally route to/contact/es/robots.txt->404, not/robots.txt/es/sitemap.xml->404, not/sitemap.xml/es/api/foo->404, not/api/fooCurrent API Limitation
Today
rewrite.input({ url })runs before route matching and only receives the public URL.That means I can turn
/es/robots.txtinto/robots.txt, but the rewrite function has no supported way to know that the candidate internal URL/robots.txtpoints to a server-only route. So the same locale stripping logic that works for pages also makes localized variants of server-only routes accessible.By “server-only route,” I mean a route handled by
server.handlersthat does not render a UI/page route for navigation.Current Workaround
Traverse
routeTreeand inspect runtime option shape likeroute.options.server?.handlers, but that feels like relying on internals.Feature Request / Suggestion
Would TanStack consider exposing a supported way for
rewrite.inputto inspect the route for a candidate internal URL, including whether that route is server-only?A possible shape:
The exact API shape does not matter. The key capability is: rewrite logic can inspect the route for the candidate internal URL before deciding whether to return the original URL or the candidate URL.
Beta Was this translation helpful? Give feedback.
All reactions