# CorsHttpMethod

Supported CORS HTTP methods.

- Source: [`aws-apigatewayv2/lib/http/api.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-apigatewayv2/lib/http/api.ts#L216)
- Type last changed: v2.112.0 · 1 Dec 2023

## Example

TypeScript:

```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:

```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:

```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();
```

C# / .NET:

```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)
    }
});
```

Golang:

```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`](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2.CorsPreflightOptions.html).allowMethods
