Skip to content

fix(hono-adapter): always expose set-auth-token via CORS#1179

Merged
xuyushun441-sys merged 1 commit intomainfrom
copilot/fix-issue-with-pull-request-1178
Apr 17, 2026
Merged

fix(hono-adapter): always expose set-auth-token via CORS#1179
xuyushun441-sys merged 1 commit intomainfrom
copilot/fix-issue-with-pull-request-1178

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

Follow-up to #1177 and #1178. Those fixed CORS preflight and wildcard origin matching across the three Hono-based code paths, but cross-origin auth was still broken on Vercel: createHonoApp() defaulted exposeHeaders to [], diverging from plugin-hono-server (which sets ['set-auth-token'] since 151dd19c). Since apps/server routes all traffic through createHonoApp() on Vercel, browsers stripped set-auth-token from every response, preventing the better-auth bearer() plugin from delivering rotated session tokens — sessions silently broke on any cross-origin refresh even though preflight and the request both succeeded.

Changes

  • packages/adapters/hono/src/index.ts — always include set-auth-token in exposeHeaders, merged and deduped with user-supplied values; mirrors plugin-hono-server lines 155–161.
  • packages/adapters/hono/src/hono.test.ts — three new cases: default exposes set-auth-token, user-supplied exposeHeaders are merged (not replaced), no duplication when both include it.
  • CHANGELOG.md — Unreleased / Fixed entry.
// Before
app.use('*', cors({
  exposeHeaders: corsOpts.exposeHeaders || [],
  ...
}));

// After — matches plugin-hono-server invariant
const exposeHeaders = Array.from(new Set([
  'set-auth-token',
  ...(corsOpts.exposeHeaders ?? []),
]));
app.use('*', cors({ exposeHeaders, ... }));

Invariant worth preserving

All three Hono-based CORS sites must default exposeHeaders to include set-auth-token:

  1. packages/plugins/plugin-hono-server/src/hono-plugin.ts
  2. packages/adapters/hono/src/index.tscreateHonoApp()this PR
  3. Any future adapter wrapping Hono's cors()

apps/server/server/index.ts is unaffected — its short-circuit handles OPTIONS only, and Access-Control-Expose-Headers applies to actual responses, which flow through createHonoApp().

…igin auth

Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/343b8511-f629-420e-b9aa-2a850e84ce47

Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectstack-demo Ready Ready Preview, Comment Apr 17, 2026 11:38am
spec Ready Ready Preview, Comment Apr 17, 2026 11:38am

Request Review

@xuyushun441-sys xuyushun441-sys marked this pull request as ready for review April 17, 2026 11:38
@xuyushun441-sys xuyushun441-sys merged commit 0e7e932 into main Apr 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants