CorsHttpMethod Enum
Supported CORS HTTP methods.
| Source | aws-apigatewayv2/lib/http/api.ts |
|---|---|
| Type last changed |
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
| Member | Description |
|---|---|
ANY | HTTP ANY. |
DELETE | HTTP DELETE. |
GET | HTTP GET. |
HEAD | HTTP HEAD. |
OPTIONS | HTTP OPTIONS. |
PATCH | HTTP PATCH. |
POST | HTTP POST. |
PUT | HTTP PUT. |
Referenced by
CorsPreflightOptions.allowMethodsallow_methodsallowMethodsAllowMethodsAllowMethods