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
originssetting (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-agesetting (Access-Control-Max-Age) is the duration in seconds for which the result of preflight requests should be cached. - The
headerssetting (controls bothAccess-Control-Allow-HeadersandAccess-Control-Expose-Headers) can be used to allow headers in addition to the (always allowed) simple response headersCache-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/jsonor theX-XSRF-TOKENheader of CSRF protection, must be listed here; without this setting, preflight requests that ask for such headers fail. - The
entrystore.cors.origins.allow-credentialssetting affectsAccess-Control-Allow-Credentialsand determines whether cookies may be sent for origins that match the patterns. In 6.x,Access-Control-Allow-Credentials: trueis only sent to these origins, also in responses to preflight requests. Access-Control-Allow-Methodsis set toHEAD, GET, PUT, POST, DELETE, OPTIONSin 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.