Skip to main content

CloudFrontCorsSchema

The CORS headers a response headers policy adds, which let a page on another origin call this distribution from a browser. They replace any CORS headers the origin sent.

@group

Resources/CloudFrontDistribution

Index

Properties

allowCredentials

allowCredentials: boolean

Whether to send Access-Control-Allow-Credentials: true, which lets the calling page send cookies and Authorization, and read the response. A browser refuses such a response when the allowed origin is *, so name the origins in allowOrigins.

allowHeaders

allowHeaders: string[]

The request headers the calling page may send, e.g. ['Content-Type', 'x-session-id']. A name may use * for any run of characters, e.g. x-app-*. * alone allows every header except Authorization, which must be named. Header names are not case-sensitive.

allowMethods

allowMethods: (GET | HEAD | OPTIONS | PUT | POST | PATCH | DELETE | ALL)[]

The methods the calling page may use. See ICloudFrontCorsMethod.

allowOrigins

allowOrigins: string[]

The origins allowed to call, each a scheme, a host, and a port when it is not the default, e.g. https://app.example.com. Write them in lowercase, as browsers send them.

  • * allows every origin.
  • * may stand for the leftmost subdomains, e.g. https://*.example.com, which matches https://www.example.com and https://a.b.example.com, but not https://example.com.
  • * may stand for port digits, e.g. https://example.com:*.
  • An origin without a scheme, e.g. example.com, matches both http and https.

maxAgeSeconds

maxAgeSeconds: number

How long a browser may reuse the answer to a preflight request, in seconds. Browsers cap it: Chrome at 7200, Firefox at 86400.