interface CorsProperty
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.Lambda.CfnUrl.CorsProperty |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awslambda#CfnUrl_CorsProperty |
Java | software.amazon.awscdk.services.lambda.CfnUrl.CorsProperty |
Python | aws_cdk.aws_lambda.CfnUrl.CorsProperty |
TypeScript | aws-cdk-lib » aws_lambda » CfnUrl » CorsProperty |
The Cross-Origin Resource Sharing (CORS) settings for your function URL. Use CORS to grant access to your function URL from any origin. You can also use CORS to control access for specific HTTP headers and methods in requests to your function URL.
See also: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-url-cors.html
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_lambda as lambda } from 'aws-cdk-lib';
const corsProperty: lambda.CfnUrl.CorsProperty = {
allowCredentials: false,
allowHeaders: ['allowHeaders'],
allowMethods: ['allowMethods'],
allowOrigins: ['allowOrigins'],
exposeHeaders: ['exposeHeaders'],
maxAge: 123,
};
Properties
Name | Type | Description |
---|---|---|
allow | boolean | IResolvable | Whether you want to allow cookies or other credentials in requests to your function URL. |
allow | string[] | The HTTP headers that origins can include in requests to your function URL. |
allow | string[] | The HTTP methods that are allowed when calling your function URL. |
allow | string[] | The origins that can access your function URL. |
expose | string[] | The HTTP headers in your function response that you want to expose to origins that call your function URL. |
max | number | The maximum amount of time, in seconds, that browsers can cache results of a preflight request. |
allowCredentials?
Type:
boolean |
IResolvable
(optional)
Whether you want to allow cookies or other credentials in requests to your function URL.
The default is false
.
allowHeaders?
Type:
string[]
(optional)
The HTTP headers that origins can include in requests to your function URL.
For example: Date
, Keep-Alive
, X-Custom-Header
.
allowMethods?
Type:
string[]
(optional)
The HTTP methods that are allowed when calling your function URL.
For example: GET
, POST
, DELETE
, or the wildcard character ( *
).
allowOrigins?
Type:
string[]
(optional)
The origins that can access your function URL.
You can list any number of specific origins, separated by a comma. For example: https://www.example.com
, http://localhost:60905
.
Alternatively, you can grant access to all origins with the wildcard character ( *
).
exposeHeaders?
Type:
string[]
(optional)
The HTTP headers in your function response that you want to expose to origins that call your function URL.
For example: Date
, Keep-Alive
, X-Custom-Header
.
maxAge?
Type:
number
(optional)
The maximum amount of time, in seconds, that browsers can cache results of a preflight request.
By default, this is set to 0
, which means the browser will not cache results.