Skip to content
v2.278.0

CorsHttpMethod Enum ​

Supported CORS HTTP methods.

Example ​

ts
new apigwv2.HttpApi(this, 'HttpProxyApi', {
  corsPreflight: {
    allowHeaders: ['Authorization'],
    allowMethods: [
      apigwv2.CorsHttpMethod.GET,
      apigwv2.CorsHttpMethod.HEAD,
      apigwv2.CorsHttpMethod.OPTIONS,
      apigwv2.CorsHttpMethod.POST,
    ],
    allowOrigins: ['*'],
    maxAge: Duration.days(10),
  },
});
python
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)
    )
)
java
HttpApi.Builder.create(this, "HttpProxyApi")
        .corsPreflight(CorsPreflightOptions.builder()
                .allowHeaders(List.of("Authorization"))
                .allowMethods(List.of(CorsHttpMethod.GET, CorsHttpMethod.HEAD, CorsHttpMethod.OPTIONS, CorsHttpMethod.POST))
                .allowOrigins(List.of("*"))
                .maxAge(Duration.days(10))
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
new HttpApi(this, "HttpProxyApi", new HttpApiProps {
    CorsPreflight = new CorsPreflightOptions {
        AllowHeaders = new [] { "Authorization" },
        AllowMethods = new [] { CorsHttpMethod.GET, CorsHttpMethod.HEAD, CorsHttpMethod.OPTIONS, CorsHttpMethod.POST },
        AllowOrigins = new [] { "*" },
        MaxAge = Duration.Days(10)
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
apigwv2.NewHttpApi(this, jsii.String("HttpProxyApi"), &HttpApiProps{
	CorsPreflight: &CorsPreflightOptions{
		AllowHeaders: []*string{
			jsii.String("Authorization"),
		},
		AllowMethods: []CorsHttpMethod{
			apigwv2.CorsHttpMethod_GET,
			apigwv2.CorsHttpMethod_HEAD,
			apigwv2.CorsHttpMethod_OPTIONS,
			apigwv2.CorsHttpMethod_POST,
		},
		AllowOrigins: []*string{
			jsii.String("*"),
		},
		MaxAge: awscdk.Duration_Days(jsii.Number(10)),
	},
})

Members ​

MemberDescription
ANYHTTP ANY.
DELETEHTTP DELETE.
GETHTTP GET.
HEADHTTP HEAD.
OPTIONSHTTP OPTIONS.
PATCHHTTP PATCH.
POSTHTTP POST.
PUTHTTP PUT.

Referenced by ​