CORS
Configuration for returning cross-origin resource sharing (CORS) headers on all endpoints (healthcheck excluded). Disabled by default.
Description
When enabled, overwrites any CORS headers specified via Server.Headers.
CORS headers being returned is contingent on an origin match. If neither WildcardOrigin or Origins are specified, CORS headers will never be triggered. When WildcardOrigin is true, CORS headers are always returned. Otherwise, CORS is triggered if the incoming origin matches one of the entries in Origins (including wildcard evaluation).
While WildcardOrigin will cause the Access-Control-Allow-Origin header to come back with a '\*', wildcard evaluation against the explicit Origins array happens server-side, resulting in the incoming origin being echoed back when there is a match. This has implications on browser behaviour.
|
Vary: Origin is always included so a shared cache in front of tilegroxy doesn’t serve one origin’s response to another. Preflight (OPTIONS) requests are answered with a 204 and the negotiated methods, headers and max age.
Example
-
YAML
-
JSON
server:
cors:
enabled: true
origins:
- https://*.example.com
exposedheaders:
- ETag
maxage: 600
{
"server": {
"cors": {
"enabled": true,
"origins": [
"https://*.example.com"
],
"exposedheaders": [
"ETag"
],
"maxage": 600
}
}
}
Configuration
| Parameter | Description | Type | Required | Default |
|---|---|---|---|---|
|
If true, return CORS headers and answer preflight requests |
bool |
No |
false |
|
If true, return Access-Control-Allow-Origin: '*' and ignore the |
bool |
No |
false |
|
The origins allowed to make cross-origin requests, optionally including scheme and port. A '*' can be included in the host portion to match any subdomain and '\**' can be used to wildcard match multiple subdomains. |
string[] |
No |
None |
|
The methods reported in preflight responses |
string[] |
No |
GET, HEAD, OPTIONS |
|
The request headers a caller may send, reported in preflight responses. A single entry of |
string[] |
No |
None |
|
The response headers made readable to browser scripts, beyond the handful browsers always expose. |
string[] |
No |
ETag |
|
If true, allow requests that carry cookies or HTTP authentication. Cannot be combined with WildcardOrigin, or with a wildcard in Headers or ExposedHeaders |
bool |
No |
false |
|
How long (in seconds) a browser may cache a preflight response. Zero omits the header and leaves the browser’s own default in place |
uint |
No |
0 |
| Configuration Parameter | Environment Variable |
|---|---|
|
|
|
|
|
|