Repository navigation
Conversation
… headers - Refresh the static-asset mark after a rule sets Cache-Control, so auth makes the authored file policy private for credentialed requests instead of replacing it with no-store. - Append Set-Cookie rules so the response's own cookies, including the Better Auth session, are kept. - Only count Better Auth cookies when deciding that a response needs the auth cache policy; app cookies keep the route's own policy. - Skip the outer header pass for fallback answers, so only the destination's rules apply, as in @void/edge and platform dispatch. - Docs: say where auth keeps private caching and what a platform does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the fix and the clear write-up. I reviewed it in depth and pushed a follow-up commit, and merged The core change (rules applied through How:
Left as is (noted for follow-ups, not part of #579):
|
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 933062d109
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| setsAuthCookie(c.res.headers, auth.options.advanced) || | ||
| c.req.path === '/api/auth' || | ||
| c.req.path.startsWith('/api/auth/'), |
There was a problem hiding this comment.
Preserve auth cache protection through cookie-free rewrites
In a native/local app with a public cache rule, an anonymous GET /session implemented as c.rewrite('/api/auth/get-session') loses its auth cache protection. The destination correctly emits no-store, but the source request's headerMiddleware overwrites it. These checks then see neither an auth source path nor a response cookie, so the outer auth middleware skips restoring the policy. The final auth response advertises the configured public TTL, allowing downstream caches to retain the anonymous session result. Propagate auth-response identity through recursive rewrites rather than inferring it only from the source path or Set-Cookie.
Useful? React with 👍 / 👎.
| if (emitEdgeRules && options.headerRules?.length) { | ||
| compileHeaderMiddleware(lines, options.headerRules); |
There was a problem hiding this comment.
Apply authored headers when auth fails before next
If auth initialization or auth.api.getSession() throws before next()—for example, on a transient database failure—registering the header middleware after auth means it is never entered. createErrorRenderer.onError returns the error response without applying header rules, so a configured Access-Control-Allow-Origin is absent and cross-origin clients cannot read the error response; previously the outer header middleware still decorated it. Keep non-cache header finalization outside this failure boundary, or explicitly apply it to auth error responses, while retaining auth's control over the final cache policy.
Useful? React with 👍 / 👎.
Fixes #579
Apply routing header rules through Hono's header API so configured values replace existing response headers. Keep authentication in control of private and no-store caching, including sign-in responses reached through rewrites or fallbacks.
Preserve last-match precedence and document that header rules also apply to matching error responses.
Validation: