Skip to content

fix(api): Send the browser CSRF token only over https from https pages - #131274

Merged
BYK merged 1 commit into
masterfrom
fix/api-browser-csrf-https
Nov 16, 2026
Merged

BYK merged 1 commit into
masterfrom
fix/api-browser-csrf-https

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Part of #131203. Follow-up to #131230.

Hardening for @sentry/api/browser, so a page served over https keeps its CSRF token on https. When the page, or the origin option, is https:, createBrowserFetch now attaches X-CSRFToken only to https: targets. The host rule stays the same. http: pages, such as local development servers, keep today's behavior, so nothing breaks for them.

The README's "Browser sessions" paragraph and the createBrowserFetch JSDoc describe the rule.

via @BYK.

--

View Session [Sentry]

createBrowserFetch attached X-CSRFToken to a similar host whatever the
target's scheme. From an https page it now attaches the token only to
https targets. http pages, such as local development servers, keep
sending it as before.

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot requested review from a team as code owners November 16, 2026 16:28
@sentry-junior
sentry-junior Bot requested a review from BYK November 16, 2026 16:28
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 16, 2026
@BYK
BYK merged commit b8e4142 into master Nov 16, 2026
88 checks passed
@BYK
BYK deleted the fix/api-browser-csrf-https branch November 16, 2026 16:39

This branch was successfully deployed

1 active deployment
Preview — 7ca0a020 Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant