Skip to content
v2.274.0

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

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.

maxAgeoptionalDurationmax_ageoptionalDurationmaxAgeoptionalDurationMaxAgeoptionalDurationMaxAgeoptionalDuration#
The time in seconds that your browser is to cache the preflight response for the specified resource.

Default: Browser default of 5 seconds.