[GH-ISSUE #5536] @better-auth/expo with phoneNumber - MISSING_OR_NULL_ORIGIN #18907

Closed
opened 2026-04-15 17:36:23 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @ArvidAnderson on GitHub (Oct 24, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/5536

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Upgrade @better-auth/expo and better-auth to 1.3.29
  2. Try to sign in using phoneNumber.verify
  3. Get response of {"code": "MISSING_OR_NULL_ORIGIN", "message": "Missing or null Origin", "status": 403, "statusText": ""}

Current vs. Expected behavior

Current Behavior:
When attempting to sign in using phoneNumber.verify with @better-auth/expo and better-auth version 1.3.29, the request fails with a 403 Forbidden error. The response returns {"code": "MISSING_OR_NULL_ORIGIN", "message": "Missing or null Origin", "status": 403, "statusText": ""}, indicating that the authentication service is rejecting the request due to a missing or null Origin header.

Expected Behavior:
The phoneNumber.verify request should return a successful response, allowing the user to complete the sign-in process.

What version of Better Auth are you using?

1.3.29

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.0.0: Wed Sep 17 21:41:50 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6030",
    "release": "25.0.0",
    "cpuCount": 11,
    "cpuModel": "Apple M3 Pro",
    "totalMemory": "36.00 GB",
    "freeMemory": "2.45 GB"
  },
  "node": {
    "version": "v22.13.1",
    "env": "development"
  },
  "packageManager": {
    "name": "bun",
    "version": "1.3.1"
  },
  "frameworks": null,
  "databases": null,
  "betterAuth": {
    "version": "1.3.29",
    "config": null
  }
}

Which area(s) are affected? (Select all that apply)

Client, Backend

Auth config (if applicable)


Additional context

No response

Originally created by @ArvidAnderson on GitHub (Oct 24, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/5536 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Upgrade @better-auth/expo and better-auth to 1.3.29 2. Try to sign in using phoneNumber.verify 3. Get response of `{"code": "MISSING_OR_NULL_ORIGIN", "message": "Missing or null Origin", "status": 403, "statusText": ""}` ### Current vs. Expected behavior **Current Behavior:** When attempting to sign in using phoneNumber.verify with @better-auth/expo and better-auth version 1.3.29, the request fails with a 403 Forbidden error. The response returns `{"code": "MISSING_OR_NULL_ORIGIN", "message": "Missing or null Origin", "status": 403, "statusText": ""}, indicating that the authentication service is rejecting the request due to a missing or null Origin header.` **Expected Behavior:** The phoneNumber.verify request should return a successful response, allowing the user to complete the sign-in process. ### What version of Better Auth are you using? 1.3.29 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.0.0: Wed Sep 17 21:41:50 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6030", "release": "25.0.0", "cpuCount": 11, "cpuModel": "Apple M3 Pro", "totalMemory": "36.00 GB", "freeMemory": "2.45 GB" }, "node": { "version": "v22.13.1", "env": "development" }, "packageManager": { "name": "bun", "version": "1.3.1" }, "frameworks": null, "databases": null, "betterAuth": { "version": "1.3.29", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Client, Backend ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-15 17:36:23 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 24, 2025):

This error is caused by a recent change in better-auth v1.3.29 that enforces stricter Origin header checks for POST requests using cookies. If the Origin or Referer header is missing or null, the backend now returns a 403 MISSING_OR_NULL_ORIGIN error. This is a security measure to prevent CSRF attacks, but it can break mobile flows (like Expo) where the Origin header is often not set automatically (details).

To resolve this for Expo/mobile:

  • Make sure your better-auth config includes all relevant trustedOrigins, such as "exp://*" and your custom scheme (e.g., "myapp://*").
  • If you are in a development environment and need to bypass this check, you can set advanced: { disableOriginCheck: true } in your better-auth config. This disables the strict Origin check, but only use this in isolated dev environments as it reduces CSRF protection (reference).
  • There is no built-in dev mode or automatic relaxation for mobile; strict CSRF protection is enforced by default (reference).
  • If you want to debug further, log the actual Origin and Referer headers received by your backend to see what (if anything) is being sent from your Expo client.

If you need to support production mobile flows, you may need to customize your client to send an Origin header, or coordinate with the better-auth maintainers for a mobile-friendly solution. For now, the config workaround above should unblock you in development.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3442117297 --> @dosubot[bot] commented on GitHub (Oct 24, 2025): <!-- Answer --> This error is caused by a recent change in better-auth v1.3.29 that enforces stricter Origin header checks for POST requests using cookies. If the Origin or Referer header is missing or null, the backend now returns a 403 MISSING_OR_NULL_ORIGIN error. This is a security measure to prevent CSRF attacks, but it can break mobile flows (like Expo) where the Origin header is often not set automatically ([details](https://github.com/better-auth/better-auth/pull/5411)). To resolve this for Expo/mobile: - Make sure your better-auth config includes all relevant trustedOrigins, such as `"exp://*"` and your custom scheme (e.g., `"myapp://*"`). - If you are in a development environment and need to bypass this check, you can set `advanced: { disableOriginCheck: true }` in your better-auth config. This disables the strict Origin check, but only use this in isolated dev environments as it reduces CSRF protection ([reference](https://github.com/better-auth/better-auth/pull/5411)). - There is no built-in dev mode or automatic relaxation for mobile; strict CSRF protection is enforced by default ([reference](https://github.com/better-auth/better-auth/issues/3743)). - If you want to debug further, log the actual Origin and Referer headers received by your backend to see what (if anything) is being sent from your Expo client. If you need to support production mobile flows, you may need to customize your client to send an Origin header, or coordinate with the better-auth maintainers for a mobile-friendly solution. For now, the config workaround above should unblock you in development. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/3e7f1de8-e7fa-46c7-b0e4-9d59465cf5d0?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/3e7f1de8-e7fa-46c7-b0e4-9d59465cf5d0?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/3e7f1de8-e7fa-46c7-b0e4-9d59465cf5d0?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/3e7f1de8-e7fa-46c7-b0e4-9d59465cf5d0?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3e7f1de8-e7fa-46c7-b0e4-9d59465cf5d0?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/3e7f1de8-e7fa-46c7-b0e4-9d59465cf5d0?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/3e7f1de8-e7fa-46c7-b0e4-9d59465cf5d0?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5536)
Author
Owner

@R5dan commented on GitHub (Oct 24, 2025):

@ArvidAnderson Can you show an attempt to make the request? Is it failing for any other requests? Do you know if you are sending cookies

<!-- gh-comment-id:3442130234 --> @R5dan commented on GitHub (Oct 24, 2025): @ArvidAnderson Can you show an attempt to make the request? Is it failing for any other requests? Do you know if you are sending [cookies](https://www.better-auth.com/docs/integrations/expo#making-authenticated-requests-to-your-server)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#18907