Skip to content

CORS

Plenum handles CORS at the gateway level, so your backends don’t need to. CORS is configured per-operation via the x-plenum-cors extension.

Working example: see examples/cors/

Add x-plenum-cors to an operation via an overlay:

actions:
- target: "$.paths['/products'].get"
update:
x-plenum-cors:
origins:
- "https://example.com"
methods: [GET]
headers: [Content-Type, Authorization]
FieldDefaultDescription
originsAllowed origins (required)
methodsGET, POST, HEADAllowed HTTP methods
headersAllowed request headers
allow-credentialsfalseAllow credentials
max-age86400Preflight cache duration (seconds)
expose-headersResponse headers exposed to the browser

Origins support three patterns:

PatternExampleMatches
Exacthttps://example.comOnly that origin
Glob prefix*.example.comAny subdomain
Wildcard*Any origin (incompatible with allow-credentials: true)

When a browser sends a preflight OPTIONS request, Plenum responds with a 204 directly — the request never reaches your backend. The response includes the configured CORS headers.

Operations without x-plenum-cors do not receive any CORS headers. Requests to those endpoints are proxied as normal.