Skip to content

Conversation

@acolomb
Copy link
Member

@acolomb acolomb commented Nov 1, 2020

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-Methods header.

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.

This allows for checking GUI / API availability without actually doing
a GET or POST request.
@calmh calmh merged commit 7dc0c6a into syncthing:main Nov 1, 2020
@acolomb acolomb deleted the allow-options-in-api-cors branch November 1, 2020 14:29
@calmh calmh added this to the v1.12.0 milestone Nov 3, 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
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Nov 2, 2021
@syncthing syncthing locked and limited conversation to collaborators Nov 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants