Skip to content

feat: make withCredentials configurable on the connection builder - #278

Merged
JacobAtchley merged 2 commits into
mainfrom
forks/mcarey/configurable-with-credentials
Sep 21, 2026
Merged

JacobAtchley merged 2 commits into
mainfrom
forks/mcarey/configurable-with-credentials

Conversation

@mcarey1590

@mcarey1590 mcarey1590 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Adds withCredentials(include: boolean) to RealTimeEventsConnectionBuilder, wired into the IHttpConnectionOptions passed to withUrl.

Default stays true, matching SignalR's own default, so existing consumers see no behaviour change.

Why

SignalR sends credentials by default. A credentialed cross-origin request forbids a wildcard Access-Control-Allow-Origin or Access-Control-Allow-Headers — the browser rejects the negotiate preflight, and the failure usually surfaces as an opaque network error rather than a readable CORS message.

Consumers whose hub is authenticated with a bearer token rather than a cookie gain nothing from credentials mode, but still pay for it: their server has to echo the request origin and enumerate every request header the client sends. Opting out lets a permissive CORS configuration serve the preflight.

This came out of a live incident. A HAProxy ingress upgrade began emitting a literal * where the previous version echoed request values, which broke every negotiate call in two environments. The infrastructure-side fix works but requires a hand-maintained header allowlist, and that list has already caused one outage of its own when it was incomplete. Being able to drop credentials mode removes the need for that list entirely.

How to test

npx nx run-many -t lint test build --projects=web-socket-client

Two tests added, both watched failing before the implementation existed:

  • should send credentials by default — asserts withUrl receives withCredentials: true with no configuration.
  • should omit credentials when the consumer opts out — asserts withCredentials(false) propagates.

31 tests pass, lint clean, build clean.

Notes for reviewers

  • README gains a Credentials and CORS section explaining when to opt out and when not to. The builder options table lists the new method.
  • No consumer bump here. platform-ui pins @firebend/control-tower-web-socket-client and should move only after this publishes.

Merge after #279

An earlier version of this description said the feat: prefix would cut a minor via versionize. Both halves of that were wrong. This repo does not use versionize — it uses .github/scripts/pub.sh — and that script mapped feat to major, with minor unreachable from any conventional prefix.

#279 corrects the mapping. Merged before it, this PR publishes 2.0.0 and advertises a breaking change that does not exist. Merged after it, it publishes 1.8.0, which is what an additive, backward-compatible option should be.

Note also that the repo's checked-in version (1.7.3) trails the registry (1.7.4), which #279 also addresses.

🤖 Generated with Claude Code

tnschneider
tnschneider previously approved these changes Sep 21, 2026
mcarey1590 and others added 2 commits September 21, 2026 14:23
SignalR sends credentials by default, and a credentialed cross-origin
request forbids a wildcard Access-Control-Allow-Origin or
Access-Control-Allow-Headers. Consumers whose hub is authenticated with a
bearer token rather than a cookie gain nothing from credentials mode but
still pay for it: their negotiate preflight is rejected unless the server
echoes the request origin and enumerates every request header.

Add withCredentials(include) so those consumers can opt out. The default
stays true, matching SignalR's own default, so existing behaviour is
unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Branch protection on main requires a pull request, so GITHUB_TOKEN could
not push the "Release [skip-ci]" commit. Every Merge on Main run since
June failed on that step (GH006) even though npm publish had already
succeeded, leaving the pipeline red and the release tags unpushed.

pub.sh now bumps from the registry, so the version in git is no longer
the source of truth and the commit-back is dead weight. Push the tag
created by npm version and drop the forced push to main.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@mcarey1590
mcarey1590 force-pushed the forks/mcarey/configurable-with-credentials branch from 9732919 to 795d775 Compare September 21, 2026 19:25
@mcarey1590
mcarey1590 marked this pull request as ready for review September 21, 2026 19:26
@JacobAtchley
JacobAtchley merged commit 46c6bf5 into main Sep 21, 2026
1 check passed
@JacobAtchley
JacobAtchley deleted the forks/mcarey/configurable-with-credentials branch September 21, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants