FunctionUrlCorsOptions Struct
Specifies a cross-origin access property for a function URL.
Example
ts
declare const fn: lambda.Function;
fn.addFunctionUrl({
authType: lambda.FunctionUrlAuthType.NONE,
cors: {
// Allow this to be called from websites on https://example.com.
// Can also be ['*'] to allow all domain.
allowedOrigins: ['https://example.com'],
// More options are possible here, see the documentation for FunctionUrlCorsOptions
},
});
python
# fn: lambda.Function
fn.add_function_url(
auth_type=lambda_.FunctionUrlAuthType.NONE,
cors=lambda.FunctionUrlCorsOptions(
# Allow this to be called from websites on https://example.com.
# Can also be ['*'] to allow all domain.
allowed_origins=["https://example.com"]
)
)
java
Function fn;
fn.addFunctionUrl(FunctionUrlOptions.builder()
.authType(FunctionUrlAuthType.NONE)
.cors(FunctionUrlCorsOptions.builder()
// Allow this to be called from websites on https://example.com.
// Can also be ['*'] to allow all domain.
.allowedOrigins(List.of("https://example.com"))
.build())
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
Function fn;
fn.AddFunctionUrl(new FunctionUrlOptions {
AuthType = FunctionUrlAuthType.NONE,
Cors = new FunctionUrlCorsOptions {
// Allow this to be called from websites on https://example.com.
// Can also be ['*'] to allow all domain.
AllowedOrigins = new [] { "https://example.com" }
}
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var fn Function
fn.AddFunctionUrl(&FunctionUrlOptions{
AuthType: lambda.FunctionUrlAuthType_NONE,
Cors: &FunctionUrlCorsOptions{
// Allow this to be called from websites on https://example.com.
// Can also be ['*'] to allow all domain.
AllowedOrigins: []*string{
jsii.String("https://example.com"),
},
},
})
Properties
allowCredentialsoptionalbooleanallow_credentialsoptionalboolallowCredentialsoptionalBooleanAllowCredentialsoptionalboolAllowCredentialsoptional*bool= false#Whether to allow cookies or other credentials in requests to your function URL.
allowedHeadersoptionalstring[]allowed_headersoptionaltyping.List[str]allowedHeadersoptionalList<String>AllowedHeadersoptionalstring[]AllowedHeadersoptional*[]*string#Headers that are specified in the Access-Control-Request-Headers header.
Default: No headers allowed.
allowedMethodsoptionalHttpMethod[]allowed_methodsoptionaltyping.List[HttpMethod]allowedMethodsoptionalList<HttpMethod>AllowedMethodsoptionalHttpMethod[]AllowedMethodsoptional*[]HttpMethod= [HttpMethod.ALL]#An HTTP method that you allow the origin to execute.
allowedOriginsoptionalstring[]allowed_originsoptionaltyping.List[str]allowedOriginsoptionalList<String>AllowedOriginsoptionalstring[]AllowedOriginsoptional*[]*string#One or more origins you want customers to be able to access the bucket from.
Default: No origins allowed.
exposedHeadersoptionalstring[]exposed_headersoptionaltyping.List[str]exposedHeadersoptionalList<String>ExposedHeadersoptionalstring[]ExposedHeadersoptional*[]*string#One or more headers in the response that you want customers to be able to access from their applications.
Default: No headers exposed.