Skip to content

Cross-Origin Resource Sharing (CORS)

EntryStore supports simple CORS requests (HEAD, GET, POST) as well as advanced CORS with preflight requests (OPTIONS with a consequent request using any allowed HTTP verb).

Configuration

The following settings can be used to activate and configure CORS:

entrystore.cors=on|off (default: off)
entrystore.cors.origins=*.domain.com,domain.net,something.* (default: *)
entrystore.cors.origins.allow-credentials=*.internal.domain.com (default: unset)
entrystore.cors.max-age=7200 (default: unset)
entrystore.cors.headers=X-Custom-Header (optional)

In 6.x, an unrecognised value of entrystore.cors makes startup fail (see Settings).

Details

  • The origins setting (Access-Control-Allow-Origin) defines a list of allowed origins. There is limited support for wildcards: a single wildcard is supported at the beginning or at the end of an origin. An origin may also be a wildcard only without any other surrounding characters. The value of this setting is a comma-separated list. Origins are matched case-insensitively. In 6.x, a pattern with a wildcard elsewhere is ignored and an error is logged.
  • The max-age setting (Access-Control-Max-Age) is the duration in seconds for which the result of preflight requests should be cached.
  • The headers setting (controls both Access-Control-Allow-Headers and Access-Control-Expose-Headers) can be used to allow headers in addition to the (always allowed) simple response headers Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, Pragma. This value of this setting is a comma-separated list. Request headers that are not CORS-safelisted, e.g. Content-Type: application/json or the X-XSRF-TOKEN header of CSRF protection, must be listed here; without this setting, preflight requests that ask for such headers fail.
  • The entrystore.cors.origins.allow-credentials setting affects Access-Control-Allow-Credentials and determines whether cookies may be sent for origins that match the patterns. In 6.x, Access-Control-Allow-Credentials: true is only sent to these origins, also in responses to preflight requests.
  • Access-Control-Allow-Methods is set to HEAD, GET, PUT, POST, DELETE, OPTIONS in responses to preflight requests.

EntryStore 5.x

5.x sends Access-Control-Allow-Credentials: true in every response to a preflight request from an allowed origin.