Module: lambda-controller-cors


(require("lambda-controller-cors"))(config)

A factory to create the CORS plugin object.

Parameters:
Name Type Description
config object

The configuration object for the factory

Properties:
Name Type Argument Default Description
allowed string | array <optional>
*

A domain, '*' or list of domains to return cors headers for.

Author:
Returns:

The mixin object suitable to be added to lambda controller as a plugin.

Type
object

Members


<inner> endpoint

Returns the full origin but without the path.

Author:

<inner> origin

Returns the origin subdomain and domain.

Author:

<inner> originAsURL

Return the origin information as a URL object

Author:
See:

Methods


<inner> cors()

If the request is a cors request and the origin is whitelisted this adds the required headers to the response.

Author:

<inner> corsOptions()

This responds to the cors preflight with the correct headers.


<inner> isAllowed()

Checks to see if the current origin is allowed on the allowed list.

Author:
Returns:

true it is allowed, false it is not.

Type
boolean

<inner> isCorsRequest()

Detects whether the origin is in the header i.e. it is an cors request

Author:
Returns:

true its a cors request, false it is not.

Type
boolean