[PR #8405] [MERGED] fix(expo): handle origin override across mutable and immutable requests #7955

Closed
opened 2026-03-13 13:54:24 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8405
Author: @NathanColosimo
Created: 3/5/2026
Status: Merged
Merged: 3/5/2026
Merged by: @bytaesu

Base: canaryHead: fix/expo-bun-request-cloning


📝 Commits (4)

  • a36a934 fix(expo) - mutate headers in place
  • 2b416f0 update to try with cloudflare workers
  • 23249e0 test: add regression case
  • b87fda3 Merge branch 'canary' into fix/expo-bun-request-cloning

📊 Changes

2 files changed (+111 additions, -8 deletions)

View changed files

📝 packages/expo/src/index.ts (+11 -8)
📝 packages/expo/test/expo.test.ts (+100 -0)

📄 Description

Closes #8404

Tested patching node_modules locally as well in my project and this fixed it.

Essentially, new Request() breaks with bun sometimes, and this changes the already-existing expo fix that copied headers over to a new Request instead to mutate the headers in place to prevent breaking with Bun runtimes.


Summary by cubic

Update Expo middleware to mutate the origin header directly on the incoming Request to avoid Bun route matching issues. If header mutation isn’t allowed (e.g., Cloudflare Workers), fall back to creating a new Request with updated headers; regression tests confirm we preserve the original Request when mutation works and clone when it fails.

Written for commit b87fda3e53. 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/8405 **Author:** [@NathanColosimo](https://github.com/NathanColosimo) **Created:** 3/5/2026 **Status:** ✅ Merged **Merged:** 3/5/2026 **Merged by:** [@bytaesu](https://github.com/bytaesu) **Base:** `canary` ← **Head:** `fix/expo-bun-request-cloning` --- ### 📝 Commits (4) - [`a36a934`](https://github.com/better-auth/better-auth/commit/a36a93448dff339655b22b989d8c6f2da72ea5cb) fix(expo) - mutate headers in place - [`2b416f0`](https://github.com/better-auth/better-auth/commit/2b416f092b953e42a9546af0d7a7e10d54f2f3eb) update to try with cloudflare workers - [`23249e0`](https://github.com/better-auth/better-auth/commit/23249e06c6463167383854c4455b4d96a1f0ae4e) test: add regression case - [`b87fda3`](https://github.com/better-auth/better-auth/commit/b87fda3e5398ea3bf9ee8da9a7479abec87c1cf5) Merge branch 'canary' into fix/expo-bun-request-cloning ### 📊 Changes **2 files changed** (+111 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `packages/expo/src/index.ts` (+11 -8) 📝 `packages/expo/test/expo.test.ts` (+100 -0) </details> ### 📄 Description Closes #8404 Tested patching node_modules locally as well in my project and this fixed it. Essentially, new Request() breaks with bun sometimes, and this changes the already-existing expo fix that copied headers over to a new Request instead to mutate the headers in place to prevent breaking with Bun runtimes. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Update Expo middleware to mutate the origin header directly on the incoming Request to avoid Bun route matching issues. If header mutation isn’t allowed (e.g., Cloudflare Workers), fall back to creating a new Request with updated headers; regression tests confirm we preserve the original Request when mutation works and clone when it fails. <sup>Written for commit b87fda3e5398ea3bf9ee8da9a7479abec87c1cf5. 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:54:24 -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#7955