(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. |
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.
-
<inner> origin
-
Returns the origin subdomain and domain.
-
<inner> originAsURL
-
Return the origin information as a URL object
Methods
-
<inner> cors()
-
If the request is a cors request and the origin is whitelisted this adds the required headers to the response.
-
<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.
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
Returns:
true its a cors request, false it is not.
- Type
- boolean