Skip to content

flask_basicauth.py: add BASIC_AUTH_ALLOW_OPTIONS override flag#14

Open
megahall wants to merge 1 commit into
jpvanhal:masterfrom
megahall:master
Open

flask_basicauth.py: add BASIC_AUTH_ALLOW_OPTIONS override flag#14
megahall wants to merge 1 commit into
jpvanhal:masterfrom
megahall:master

Conversation

@megahall

Copy link
Copy Markdown

CORS requires pre-flight OPTIONS method requests to work without the Authorization header from the browser.

Otherwise, the browser will raise CORS errors on calls to any endpoints protected with basic auth, and the requests will not work properly. Here is an example error message from Chrome: Failed to load https://host:port/api_url: Response for preflight has invalid HTTP status code 401.

With the BASIC_AUTH_ALLOW_OPTIONS config option enabled, the OPTIONS requests are allowed, and Flask-CORS can send back the right response for the browser, so that the endpoints will work with CORS enabled.

whitelists OPTIONS method requests for compatibility with Flask-CORS
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.

1 participant