Skip to content
v2.273.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 ​

allowCredentialsbooleanallow_credentialsboolallowCredentialsBooleanAllowCredentialsboolAllowCredentials*bool= false#
Whether to allow cookies or other credentials in requests to your function URL.
allowedHeadersstring[]allowed_headerstyping.List[str]allowedHeadersList<String>AllowedHeadersstring[]AllowedHeaders*[]*string= No headers allowed.#
Headers that are specified in the Access-Control-Request-Headers header.
allowedMethodsHttpMethod[]allowed_methodstyping.List[HttpMethod]allowedMethodsList<HttpMethod>AllowedMethodsHttpMethod[]AllowedMethods*[]HttpMethod= [HttpMethod.ALL]#
An HTTP method that you allow the origin to execute.
allowedOriginsstring[]allowed_originstyping.List[str]allowedOriginsList<String>AllowedOriginsstring[]AllowedOrigins*[]*string= No origins allowed.#
One or more origins you want customers to be able to access the bucket from.
exposedHeadersstring[]exposed_headerstyping.List[str]exposedHeadersList<String>ExposedHeadersstring[]ExposedHeaders*[]*string= No headers exposed.#
One or more headers in the response that you want customers to be able to access from their applications.
maxAgeDurationmax_ageDurationmaxAgeDurationMaxAgeDurationMaxAgeDuration= Browser default of 5 seconds.#
The time in seconds that your browser is to cache the preflight response for the specified resource.