Allow the QUERY method (RFC 10008) by default - #413
Draft
rpodgorny wants to merge 1 commit into
Draft
Conversation
QUERY is the safe, idempotent method with a request body standardized in RFC 10008 (June 2026). It is not CORS-safelisted, so cross-origin use is preflighted, exactly like PUT, PATCH and DELETE. Because QUERY was missing from ALL_METHODS, a preflight carrying `Access-Control-Request-Method: QUERY` failed the membership check in get_cors_headers, which drops the entire Access-Control-Allow-Methods header rather than emitting a list without QUERY. The browser then blocked the request, and the response gave no hint as to why. Flask already routes `methods=["QUERY"]` and parses the body, so the server side works today; only the CORS default was out of date. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
QUERYis the safe, idempotent method with a request body standardized in RFC 10008 (June 2026). It is not CORS-safelisted, so cross-origin use is preflighted, exactly likePUT,PATCHandDELETE.Because
QUERYwas missing fromALL_METHODS, a preflight carryingAccess-Control-Request-Method: QUERYfails the membership check inget_cors_headers(flask_cors/core.py:330), which drops the entireAccess-Control-Allow-Methodsheader rather than emitting a list withoutQUERY. The browser then blocks the request, and the response gives no hint as to why.Measured against flask-cors 6.0.5, same app, two preflights:
Flask already routes
methods=["QUERY"]and parses the body viarequest.get_json(), so the server side works today; only the CORS default was out of date. Browsers need no update either —QUERYis neither a forbidden nor a normalized method in the Fetch standard, sofetch(url, {method: 'QUERY', body})andXMLHttpRequestalready send it in current Chromium and Firefox. The CORS default is the remaining blocker for cross-origin use.Changes
flask_cors/core.py— addQUERYtoALL_METHODSflask_cors/decorator.py,flask_cors/extension.py— update the documented default in themethodsdocstringstests/decorator/test_methods.py— regression test asserting a default-configQUERYpreflight getsAccess-Control-Allow-MethodsCHANGELOG.md— entry underUnreleasedChecks
make test— 99 passed, 1 skippedmake check— mypy clean, deptry clean, lock file consistentcore.pychange (AssertionError: unexpectedly None)Notes
Users on released versions can work around this today with an explicit list:
Two unrelated things noticed while following CONTRIBUTING, not addressed here:
make checkis a no-op — the pre-commit line in theMakefileis commented out (# @uv run pre-commit run -a).ruffhook fails on this repo's ownpyproject.tomlwithUnknown rule selector: TC; the ruff version pinned in.pre-commit-config.yamlpredates that selector.Happy to adjust naming, test placement, or drop the code comment if you'd rather keep the constant bare.
🤖 Generated with Claude Code