Socket
Book a DemoInstallSign in
Socket

control-access

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

control-access

Easy CORS handling

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

control-access Build Status

Easy CORS handling

Install

$ npm install control-access

Usage

const controlAccess = require('control-access');

module.exports = (req, res) => {
	controlAccess()(req, res);
	res.end('unicorns');
};

API

controlAccess([options])(request, response)

options

Type: Object

allowCredentials

Type: boolean

Access-Control-Allow-Credentials indicates whether or not the response to the request can be exposed when the credentials flag is true.

Can be set globally with the ACCESS_ALLOW_CREDENTIALS environment variable. Possible values are 1 and 0.

allowHeaders

Type: Array string

Access-Control-Allow-Headers is used in response to a preflight request to indicate which HTTP headers can be used when making the actual request.

Can be set globally with the ACCESS_ALLOW_HEADERS environment variable using a comma delimited string.

allowMethods

Type: Array string

Access-Control-Allow-Methods specifies the method or methods allowed when accessing the resource.

Can be set globally with the ACCESS_ALLOW_METHODS environment variable using a comma delimited string.

allowOrigin

Type: string

Access-Control-Allow-Origin specifies a URI that may access the resource.

Can be set globally with the ACCESS_ALLOW_ORIGIN environment variable.

exposeHeaders

Type: Array string

Access-Control-Expose-Headers response header indicates which headers can be exposed as part of the response.

Can be set globally with the ACCESS_EXPOSE_HEADERS environment variable using a comma delimited string.

maxAge

Type: number

Access-Control-Max-Age indicates how long the results of a preflight request can be cached.

Can be set globally with the ACCESS_MAX_AGE environment variable.

request

Type: http.IncomingMessage

Incoming HTTP request.

response

Type: http.ServerResponse

Response object.

  • micro-access - Easy CORS handling for micro

License

MIT © Kevin Mårtensson

Keywords

access

FAQs

Package last updated on 13 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts