CORS
The cors block configures the CORS (Cross-Origin Resource Sharing) behavior in Couper.
| Block name | Context | Label |
|---|---|---|
cors | Server Block, Files Block, SPA Block, API Block. | no label |
Note: Access-Control-Allow-Methods is only sent in response to a CORS preflight request, if the method requested by Access-Control-Request-Method is an allowed method (see the allowed_method attribute for api or endpoint blocks).
Attribute allowed_origins
Can be either of: a string with a single specific origin, "*" (all origins are allowed) or an array of specific origins.
Example:
allowed_origins = ["https://www.example.com", "https://www.another.host.org"]
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
allow_credentials | bool | false | Set to |
allowed_origins | object | - | An allowed origin or a list of allowed origins. |
disable | bool | false | Set to |
max_age | duration | - | Indicates the time the information provided by the |
Duration
Example: timeout = "300s"
| Duration units | Description |
|---|---|
ns | nanoseconds |
us (or ยตs) | microseconds |
ms | milliseconds |
s | seconds |
m | minutes |
h | hours |