[PR #7462] [CLOSED] chore(docs): clarify access-control-expose-headers management by BA #7329

Closed
opened 2026-03-13 13:32:23 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7462
Author: @Diabl0570
Created: 1/19/2026
Status: Closed

Base: canaryHead: canary


📄 Description

Problem

When CORS middleware (e.g., Hono's cors) sets the exposeHeaders option, it overrides Better Auth's automatic access-control-expose-headers header management. This breaks functionality for plugins that expose authentication headers:

  • Bearer plugin: set-auth-token
  • JWT plugin: set-auth-jwt
  • One-time-token plugin: set-ott

These plugins read existing access-control-expose-headers and append their headers, but when CORS middleware sets exposeHeaders, it overwrites the header.

Solution

Updated documentation to:

  1. Remove exposeHeaders from the default Hono CORS example
  2. Add CORS configuration warnings to affected plugin docs explaining:
    • Better Auth automatically manages header exposure
    • If using exposeHeaders, users must include Better Auth headers in the list
    • Examples showing proper configuration for Hono and Express

Files Changed

  • docs/content/docs/integrations/hono.mdx - Removed exposeHeaders from example, added warning
  • docs/content/docs/plugins/bearer.mdx - Added CORS configuration section
  • docs/content/docs/plugins/jwt.mdx - Added CORS configuration section
  • docs/content/docs/plugins/one-time-token.mdx - Added CORS configuration section

Summary by cubic

Clarifies that Better Auth manages access-control-expose-headers and how CORS exposeHeaders/exposedHeaders can override it, which can break auth headers. Updates docs: remove exposeHeaders from the Hono CORS example, add CORS callouts with Hono/Express examples in Bearer, JWT, and One-Time Token pages, and document One-Time Token options (setOttHeaderOnNewSession, disableSetSessionCookie).

Written for commit ab7ec8a70b. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7462 **Author:** [@Diabl0570](https://github.com/Diabl0570) **Created:** 1/19/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `canary` --- ### 📄 Description ### Problem When CORS middleware (e.g., Hono's `cors`) sets the `exposeHeaders` option, it overrides Better Auth's automatic `access-control-expose-headers` header management. This breaks functionality for plugins that expose authentication headers: - **Bearer plugin**: `set-auth-token` - **JWT plugin**: `set-auth-jwt` - **One-time-token plugin**: `set-ott` These plugins read existing `access-control-expose-headers` and append their headers, but when CORS middleware sets `exposeHeaders`, it overwrites the header. ### Solution Updated documentation to: 1. Remove `exposeHeaders` from the default Hono CORS example 2. Add CORS configuration warnings to affected plugin docs explaining: - Better Auth automatically manages header exposure - If using `exposeHeaders`, users must include Better Auth headers in the list - Examples showing proper configuration for Hono and Express ### Files Changed - `docs/content/docs/integrations/hono.mdx` - Removed `exposeHeaders` from example, added warning - `docs/content/docs/plugins/bearer.mdx` - Added CORS configuration section - `docs/content/docs/plugins/jwt.mdx` - Added CORS configuration section - `docs/content/docs/plugins/one-time-token.mdx` - Added CORS configuration section <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Clarifies that Better Auth manages access-control-expose-headers and how CORS exposeHeaders/exposedHeaders can override it, which can break auth headers. Updates docs: remove exposeHeaders from the Hono CORS example, add CORS callouts with Hono/Express examples in Bearer, JWT, and One-Time Token pages, and document One-Time Token options (setOttHeaderOnNewSession, disableSetSessionCookie). <sup>Written for commit ab7ec8a70be7ea3cd61585c2cccaa9dfc8729401. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:32:23 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7329