Class FunctionUrlCorsOptions
Specifies a cross-origin access property for a function URL.
Implements
Inherited Members
Namespace: Amazon.CDK.AWS.Lambda
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class FunctionUrlCorsOptions : IFunctionUrlCorsOptions
Syntax (vb)
Public Class FunctionUrlCorsOptions Implements IFunctionUrlCorsOptions
Remarks
ExampleMetadata: infused
Examples
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" }
}
});
Synopsis
Constructors
| FunctionUrlCorsOptions() | Specifies a cross-origin access property for a function URL. |
Properties
| AllowCredentials | Whether to allow cookies or other credentials in requests to your function URL. |
| AllowedHeaders | Headers that are specified in the Access-Control-Request-Headers header. |
| AllowedMethods | An HTTP method that you allow the origin to execute. |
| AllowedOrigins | One or more origins you want customers to be able to access the bucket from. |
| ExposedHeaders | One or more headers in the response that you want customers to be able to access from their applications. |
| MaxAge | The time in seconds that your browser is to cache the preflight response for the specified resource. |
Constructors
FunctionUrlCorsOptions()
Specifies a cross-origin access property for a function URL.
public FunctionUrlCorsOptions()
Remarks
ExampleMetadata: infused
Examples
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" }
}
});
Properties
AllowCredentials
Whether to allow cookies or other credentials in requests to your function URL.
public bool? AllowCredentials { get; set; }
Property Value
bool?
Remarks
Default: false
AllowedHeaders
Headers that are specified in the Access-Control-Request-Headers header.
public string[]? AllowedHeaders { get; set; }
Property Value
string[]
Remarks
Default: - No headers allowed.
AllowedMethods
An HTTP method that you allow the origin to execute.
public HttpMethod[]? AllowedMethods { get; set; }
Property Value
Remarks
Default: - [HttpMethod.ALL]
AllowedOrigins
One or more origins you want customers to be able to access the bucket from.
public string[]? AllowedOrigins { get; set; }
Property Value
string[]
Remarks
Default: - No origins allowed.
ExposedHeaders
One or more headers in the response that you want customers to be able to access from their applications.
public string[]? ExposedHeaders { get; set; }
Property Value
string[]
Remarks
Default: - No headers exposed.
MaxAge
The time in seconds that your browser is to cache the preflight response for the specified resource.
public Duration? MaxAge { get; set; }
Property Value
Remarks
Default: - Browser default of 5 seconds.