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

Clarify when and where CORS headers should be returned #2089

Merged
merged 1 commit into from Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/client_server/newsfragments/2089.clarification
@@ -0,0 +1 @@
Clarify when and where CORS headers should be returned.
18 changes: 15 additions & 3 deletions specification/client_server_api.rst
Expand Up @@ -242,6 +242,9 @@ recommended.

{{versions_cs_http_api}}


.. _`CORS`:

Web Browser Clients
-------------------

Expand All @@ -250,9 +253,14 @@ web browser or similar environment. In these cases, the homeserver should respon
to pre-flight requests and supply Cross-Origin Resource Sharing (CORS) headers on
all requests.

When a client approaches the server with a pre-flight (``OPTIONS``) request, the
server should respond with the CORS headers for that route. The recommended CORS
headers to be returned by servers on all requests are:
Servers MUST expect that clients will approach them with ``OPTIONS`` requests,
allowing clients to discover the CORS headers. All endpoints in this specification s
upport the ``OPTIONS`` method, however the server MUST NOT perform any logic defined
for the endpoints when approached with an ``OPTIONS`` request.

When a client approaches the server with a request, the server should respond with
the CORS headers for that route. The recommended CORS headers to be returned by
servers on all requests are:

.. code::

Expand Down Expand Up @@ -296,6 +304,10 @@ In this section, the following terms are used with specific meanings:
Well-known URI
~~~~~~~~~~~~~~

.. Note::
Servers hosting the ``.well-known`` JSON file SHOULD offer CORS headers, as
per the `CORS`_ section in this specification.

The ``.well-known`` method uses a JSON file at a predetermined location to
specify parameter values. The flow for this method is as follows:

Expand Down