feat: warn about CORS preflight requests on Web#2556
Open
CaiJingLong wants to merge 1 commit into
Open
Conversation
Detect when a request is not a CORS "simple request" and will trigger a preflight (OPTIONS) request, then emit a warning log and enrich the XMLHttpRequest.onError message with CORS guidance. Closes #2201 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
7 tasks
Contributor
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
warningLogexplaining why (non-safelisted method, custom headers, non-simple Content-Type, upload progress listener, orwithCredentials).XMLHttpRequest.onErrorerror message with CORS guidance when the request was preflighted, so users see a actionable hint instead of a generic network error.lib/src/cors.dart(corsPreflightReason) so it can be unit-tested on the VM without a browser.Closes #2201.
Test plan
dart analyze— no issuesdart format— applieddart test test/cors_preflight_test.dart -p vm— 15 tests passdio_test) — existingcorsTestsstill cover runtime behaviorGenerated with Devin