Repository navigation
lib/api: Allow OPTIONS method in CORS preflight request handling. - #7079
Merged
Merged
Conversation
This allows for checking GUI / API availability without actually doing a GET or POST request.
AudriusButkevicius
approved these changes
Nov 1, 2020
calmh
added a commit
to calmh/syncthing
that referenced
this pull request
Nov 9, 2020
* main: lib/folder: Clear pull errors when nothing is needed anymore (syncthing#7093) lib/api: Fix debug endpoints (ref syncthing#7001) (syncthing#7092) gui, man, authors: Update docs, translations, and contributors lib/config: Sanity checks on MaxConcurrentWrites (ref syncthing#7064) (syncthing#7069) lib/ur: Fix panics in failure-reporting (fixes syncthing#7090) (syncthing#7091) lib/ur: Fix panics in failure-reporting (fixes syncthing#7090) (syncthing#7091) build: Update dependencies (syncthing#7088) lib: Remove USE_BADGER experiment (syncthing#7089) build: Update notify (fixes syncthing#7063) (syncthing#7080) lib/api: Fix /rest/config path and add methods to cors (ref syncthing#7001) (syncthing#7081) lib/api: Allow OPTIONS method in CORS preflight request handling (ref syncthing#7017) (syncthing#7079) gui: Fix another undefined variable access (fixes syncthing#7077) (syncthing#7078) lib/config: Check for "msdos" when detecting FAT FS in Android (syncthing#7072) gui, man, authors: Update docs, translations, and contributors
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.