[PR #5069] [MERGED] docs: update api.mdx to improve cookies example #22654

Closed
opened 2026-04-15 21:11:50 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5069
Author: @JoBurgard
Created: 10/3/2025
Status: Merged
Merged: 3/11/2026
Merged by: @himself65

Base: canaryHead: patch-2


📝 Commits (2)

  • 8a7dd7d docs: Update api.mdx to improve cookies example
  • 6687f5f use sugesstion from cubic

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 docs/content/docs/concepts/api.mdx (+1 -1)

📄 Description

This changes the example to use headers.getSetCookie() instead of .get(...).

That way it returns an array. Otherwise it returns it as a string and setting the headers on the response will not work correctly.

I had this situation while using Elysia:

const signInResult = await auth.api.signInEmail({
  body: {
    email: result.email,
    password: result.password,
    rememberMe: result['remember-me'] === 'on',
  },
  headers: request.headers,
  returnHeaders: true,
});

// ✅ this works correctly
set.headers['set-cookie'] = signInResult.headers.getSetCookie();

// ❌ this will not work correctly (but no errors)
set.headers['set-cookie'] = signInResult.headers.get('set-cookie');

return redirect('/', 302);

Summary by cubic

Update API docs to use headers.getSetCookie() instead of headers.get('set-cookie') so examples return an array of cookies. This avoids broken Set-Cookie handling when forwarding headers in servers like Elysia.

Written for commit 6687f5fd3a. 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/5069 **Author:** [@JoBurgard](https://github.com/JoBurgard) **Created:** 10/3/2025 **Status:** ✅ Merged **Merged:** 3/11/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `patch-2` --- ### 📝 Commits (2) - [`8a7dd7d`](https://github.com/better-auth/better-auth/commit/8a7dd7d2801463619999fb6b824b349ac7237a05) docs: Update api.mdx to improve cookies example - [`6687f5f`](https://github.com/better-auth/better-auth/commit/6687f5fd3acf2251b0d26519cca51681b1112678) use sugesstion from cubic ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/concepts/api.mdx` (+1 -1) </details> ### 📄 Description This changes the example to use `headers.getSetCookie()` instead of `.get(...)`. That way it returns an array. Otherwise it returns it as a string and setting the headers on the response will not work correctly. I had this situation while using Elysia: ```ts const signInResult = await auth.api.signInEmail({ body: { email: result.email, password: result.password, rememberMe: result['remember-me'] === 'on', }, headers: request.headers, returnHeaders: true, }); // ✅ this works correctly set.headers['set-cookie'] = signInResult.headers.getSetCookie(); // ❌ this will not work correctly (but no errors) set.headers['set-cookie'] = signInResult.headers.get('set-cookie'); return redirect('/', 302); ``` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Update API docs to use headers.getSetCookie() instead of headers.get('set-cookie') so examples return an array of cookies. This avoids broken Set-Cookie handling when forwarding headers in servers like Elysia. <sup>Written for commit 6687f5fd3acf2251b0d26519cca51681b1112678. 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-04-15 21:11:50 -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#22654