CorsPreflightOptions

class aws_cdk.aws_apigatewayv2.CorsPreflightOptions(*, allow_credentials=None, allow_headers=None, allow_methods=None, allow_origins=None, expose_headers=None, max_age=None)

Bases: object

Options for the CORS Configuration.

Parameters:
  • allow_credentials (Optional[bool]) – Specifies whether credentials are included in the CORS request. Default: false

  • allow_headers (Optional[Sequence[str]]) – Represents a collection of allowed headers. Default: - No Headers are allowed.

  • allow_methods (Optional[Sequence[CorsHttpMethod]]) – Represents a collection of allowed HTTP methods. Default: - No Methods are allowed.

  • allow_origins (Optional[Sequence[str]]) – Represents a collection of allowed origins. Default: - No Origins are allowed.

  • expose_headers (Optional[Sequence[str]]) – Represents a collection of exposed headers. Default: - No Expose Headers are allowed.

  • max_age (Optional[Duration]) – The duration that the browser should cache preflight request results. Default: Duration.seconds(0)

ExampleMetadata:

infused

Example:

apigwv2.HttpApi(self, "HttpProxyApi",
    cors_preflight=apigwv2.CorsPreflightOptions(
        allow_headers=["Authorization"],
        allow_methods=[apigwv2.CorsHttpMethod.GET, apigwv2.CorsHttpMethod.HEAD, apigwv2.CorsHttpMethod.OPTIONS, apigwv2.CorsHttpMethod.POST
        ],
        allow_origins=["*"],
        max_age=Duration.days(10)
    )
)

Attributes

allow_credentials

Specifies whether credentials are included in the CORS request.

Default:

false

allow_headers

Represents a collection of allowed headers.

Default:
  • No Headers are allowed.

allow_methods

Represents a collection of allowed HTTP methods.

Default:
  • No Methods are allowed.

allow_origins

Represents a collection of allowed origins.

Default:
  • No Origins are allowed.

expose_headers

Represents a collection of exposed headers.

Default:
  • No Expose Headers are allowed.

max_age

The duration that the browser should cache preflight request results.

Default:

Duration.seconds(0)