[GH-ISSUE #1381] browser-extension-example No 'Access-Control-Allow-Origin' In content.tsx #26043

Closed
opened 2026-04-17 16:26:03 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @luz33c on GitHub (Feb 7, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/1381

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

https://github.com/better-auth/better-auth/blob/main/examples/browser-extension-example/src/auth/auth-client.ts

There is a bug in the code. The createAuthClient function is directly sending network requests. However, within a browser extension, specifically in content.js, sending network requests directly is not permitted due to security restrictions.

Instead, fetch requests initiated from content.js must be relayed through the background script using the message passing mechanism. The current implementation bypasses this necessary step

Current vs. Expected behavior

Image

What version of Better Auth are you using?

1.1.15

Provide environment information

mac os nodejs plasmo react

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

Other

Auth config (if applicable)

import { createAuthClient } from "better-auth/react";

export const authClient = createAuthClient({
	baseURL: "http://localhost:3000" /* base url of your Better Auth backend. */,
	plugins: [],
});

Additional context

No response

Originally created by @luz33c on GitHub (Feb 7, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/1381 ### Is this suited for github? - [ ] Yes, this is suited for github ### To Reproduce https://github.com/better-auth/better-auth/blob/main/examples/browser-extension-example/src/auth/auth-client.ts There is a bug in the code. The createAuthClient function is directly sending network requests. However, within a browser extension, specifically in content.js, sending network requests directly is not permitted due to security restrictions. Instead, fetch requests initiated from content.js must be relayed through the background script using the message passing mechanism. The current implementation bypasses this necessary step ### Current vs. Expected behavior ![Image](https://github.com/user-attachments/assets/0720a76d-09ea-4bd1-a7bc-624a82951d60) ### What version of Better Auth are you using? 1.1.15 ### Provide environment information ```bash mac os nodejs plasmo react ``` ### Which area(s) are affected? (Select all that apply) Other ### Auth config (if applicable) ```typescript import { createAuthClient } from "better-auth/react"; export const authClient = createAuthClient({ baseURL: "http://localhost:3000" /* base url of your Better Auth backend. */, plugins: [], }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-17 16:26:03 -05:00
Author
Owner

@ping-maxwell commented on GitHub (Feb 10, 2025):

It works on my end.
So there might be something missing in your implementation.
Did you clone the example, follow the guide, or just copy manually what you saw from the Gh?

<!-- gh-comment-id:2646838853 --> @ping-maxwell commented on GitHub (Feb 10, 2025): It works on my end. So there might be something missing in your implementation. Did you clone the example, follow the guide, or just copy manually what you saw from the Gh?
Author
Owner

@dosubot[bot] commented on GitHub (Jun 13, 2025):

Hi, @player0x3. I'm Dosu, and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • A bug was reported in the createAuthClient function of the Better Auth browser extension example.
  • The issue involves network requests being improperly sent directly from content.tsx, violating security protocols.
  • @ping-maxwell mentioned that the example works for them and suggested a possible implementation error on your part.
  • @ping-maxwell asked if the example was cloned or manually copied.

Next Steps:

  • Please confirm if this issue is still relevant to the latest version of the better-auth repository. If so, you can keep the discussion open by commenting on the issue.
  • If there is no further activity, the issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

<!-- gh-comment-id:2970840452 --> @dosubot[bot] commented on GitHub (Jun 13, 2025): Hi, @player0x3. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale. **Issue Summary:** - A bug was reported in the `createAuthClient` function of the Better Auth browser extension example. - The issue involves network requests being improperly sent directly from `content.tsx`, violating security protocols. - @ping-maxwell mentioned that the example works for them and suggested a possible implementation error on your part. - @ping-maxwell asked if the example was cloned or manually copied. **Next Steps:** - Please confirm if this issue is still relevant to the latest version of the better-auth repository. If so, you can keep the discussion open by commenting on the issue. - If there is no further activity, the issue will be automatically closed in 7 days. Thank you for your understanding and contribution!
Author
Owner

@mengxi-ream commented on GitHub (Aug 8, 2025):

This issue occurred because the content script is designed to reject requests to the Better Auth backend unless the origin is trusted. In this case, the trusted origin is https://www.plasmo.com.

<!-- gh-comment-id:3166561798 --> @mengxi-ream commented on GitHub (Aug 8, 2025): This issue occurred because the content script is designed to reject requests to the Better Auth backend unless the origin is trusted. In this case, the trusted origin is https://www.plasmo.com.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#26043