Repository navigation
feat(pages): check c.redirect() locations when typedRoutes is on - #739
Merged
Merged
Conversation
Redirects take RouteUrlInput, so an in-app path is checked against the app's routes while an external URL still typechecks. Co-authored-by: Cursor <[email protected]>
yangshun
marked this pull request as draft
November 6, 2026 23:54
Narrowing `redirect` made CloudContext an interface compared member by member, so Hono helpers such as `getCookie(c)` and functions typed with `Context` rejected it. `redirect` and `set` now start with an uncallable `this: never` signature that Hono's Context accepts, while calls still resolve to the typed signature. This drops the defineHandler overloads that worked around the same problem for `etag()`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
handlePageGet and handlePageMutation were async before the CloudContext wrappers were added. Keeping them async means any failure reaches callers as a rejected promise. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The cast turns the typedRoutes check off and nothing validates the location at runtime. Show how to check a `?redirectTo=` value before redirecting to it, and list `c.redirect()` as a `RouteUrlInput` consumer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
yangshun
marked this pull request as ready for review
November 7, 2026 02:27
cpojer
self-requested a review
November 7, 2026 09:56
The main merge kept only this branch's side of the type-safety guide, which dropped the stream client paragraph that voidzero-dev#741 added. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
c.redirect()asRouteUrlInputonCloudContext, sorouting.typedRouteschecks the location the same way as a link.URL, or anhttp:///https:///mailto:/tel:literal typechecks. A string TypeScript cannot check opts out withas Href. WithtypedRoutesoff, any string still typechecks.https://literal.Test plan
vp test run packages/void/test/integration/route-url-builder.test.ts -t "typechecks through the|checks URL strings against routes"vp run --filter void typecheck(no new errors; existing Cloudflare deploy type errors are unchanged)routing.typedRoutesrejectsc.redirect('/unknown')and acceptsc.redirect('https://example.com/login')Made with Cursor