Skip to content

🐛 Don't report withCredentials as a CORS preflight trigger - #2635

Open
uveshm003 wants to merge 1 commit into
cfug:mainfrom
uveshm003:fix/2634-credentials-preflight
Open

uveshm003 wants to merge 1 commit into
cfug:mainfrom
uveshm003:fix/2634-credentials-preflight

Conversation

@uveshm003

Copy link
Copy Markdown

collectCorsPreflightReasons (added in #2556) lists withCredentials as a preflight reason. Credentials mode does not trigger a preflight; only a non-safelisted method, non-safelisted headers or an upload listener do (MDN, Requests with credentials: a credentialed simple GET "is not preflighted"). As a result, BrowserHttpClientAdapter(withCredentials: true) logs the "will trigger a preflight (OPTIONS) request" warning on every simple GET, and network errors on such requests get a misleading "not a CORS simple request" hint.

Fix: drop the credentials reason and the now-unused withCredentials parameter. cors.dart lives under lib/src and isn't exported, so no public API changes.

Closes #2634 (auto-closed only because the wrong issue template was used).

Tests: removed the test that asserted the wrong behaviour and the withCredentials case from the combined test. dart test -p vm test/cors_preflight_test.dart (22 tests) and dart analyze --fatal-infos pass on dio_web_adapter.

Unverified: the browser test suite (-p chrome) wasn't run locally; the adapter change is the removal of one named argument.

Implementation and tests by Claude Code (Claude Opus 5.5); reviewed and submitted by me.

New Pull Request Checklist

  • I have read the Documentation
  • I have read the Agent Contribution Guidelines (required if any part of the change was produced with AI assistance)
  • I have searched for a similar pull request in the project and found none
  • I have updated this branch with the latest main branch to avoid conflicts (via merge from master or rebase)
  • I have added the required tests to prove the fix/feature I'm adding (adjusted the existing tests; the warning goes to dart:developer log, so there is no new failing test)
  • I have updated the documentation (not applicable — internal helper only)
  • I have run the tests without failures
  • I have updated the CHANGELOG.md in the corresponding package

The credentials mode does not cause a preflight; only a non-safelisted
method, non-safelisted headers or an upload listener do. Flagging it made
every credentialed simple GET log the preflight warning and get the
"not a CORS simple request" error hint.

Closes cfug#2634

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@uveshm003
uveshm003 requested a review from a team as a code owner November 7, 2026 17:02
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.

[web_adapter] CORS warning claims withCredentials forces a preflight, so every credentialed simple request is flagged

1 participant