lib/api: Allow OPTIONS method in CORS preflight request handling. #7079
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.
Purpose
Extracted from #7017, I think this change is of general utility. It reports the HTTP OPTIONS method as part of the allowed methods for the API. That is normally used as part of the CORS preflight check when doing a GET or POST request. When just trying to check API availability, a deliberate OPTIONS request is enough, but currently it fails because of the returned
Access-Control-Allow-Methodsheader.I don't see any security risks here and was hoping to get this small change into a release before #7017 is finalized, so that the probing done there actually works with as many instances as possible.
Testing
Verified that the header is set:
curl -X OPTIONS http://localhost:8384/ -v. Tested with Firefox (as part of #7017) that it no longer fails with a CORS error when doing an OPTIONS request from within the JS code.