Skip to main content

Configure CORS

FastGateway supports CORS configuration to control cross-origin requests to your APIs.

CORS Settings

SettingDescription
allowOriginsOrigins allowed to access the resource
allowMethodsHTTP methods allowed for cross-origin requests
allowHeadersHeaders that can be used in the request
exposeHeadersHeaders exposed to the browser
maxAgeHow long preflight results can be cached (seconds)
allowCredentialsWhether credentials are allowed

Configuration Example

cors:
allowOrigins:
- "https://example.com"
- "https://*.example.com"
allowMethods:
- "GET"
- "POST"
- "PUT"
- "DELETE"
allowHeaders:
- "Content-Type"
- "Authorization"
- "X-Request-ID"
exposeHeaders:
- "X-Request-ID"
- "X-Response-Time"
maxAge: 3600
allowCredentials: true

Wildcard Origins

Use * to allow all origins (not recommended for production with credentials):

cors:
allowOrigins:
- "*"
allowMethods:
- "GET"
- "POST"
allowCredentials: false

Note: When allowCredentials is true, you cannot use * for allowOrigins.