Couper Documentation

edge

CORS

The cors block configures the CORS (Cross-Origin Resource Sharing) behavior in Couper.

Block nameContextLabel
corsServer 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

NameTypeDefaultDescription
allow_credentials
bool
false

Set to true if the response can be shared with credentialed requests (containing Cookie or Authorization HTTP header fields).

allowed_origins
object
-

An allowed origin or a list of allowed origins.

disable
bool
false

Set to true to disable the inheritance of CORS from parent context.

max_age
duration
-

Indicates the time the information provided by the Access-Control-Allow-Methods and Access-Control-Allow-Headers response HTTP header fields.

Duration

Values of type duration are provided as number string followed by a unit listed below.

Example: timeout = "300s"

Duration unitsDescription
nsnanoseconds
us (or ยตs)microseconds
msmilliseconds
sseconds
mminutes
hhours