Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flask_basicauth.py: add BASIC_AUTH_ALLOW_OPTIONS override flag #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

megahall
Copy link

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