# @neil188/setaccesscontrol

> Header access control settings for CORS

Latest version **1.0.2** (published 2018-11-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @neil188/setaccesscontrol
pnpm add @neil188/setaccesscontrol
yarn add @neil188/setaccesscontrol
bun add @neil188/setaccesscontrol
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-11-02 |
| First published | 2018-08-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 8.11.x |
| Dependencies | 0 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | N Lupton |
| Maintainers | neil188 |

## Links

- npm: https://www.npmjs.com/package/@neil188/setaccesscontrol
- Repository: https://github.com/Neil188/setaccesscontrol
- Homepage: https://github.com/Neil188/setaccesscontrol#readme
- Issues: https://github.com/Neil188/setaccesscontrol/issues
- npm.io page: https://npm.io/package/@neil188/setaccesscontrol

## Recent versions

- 1.0.2 (latest) — 2018-11-02
- 1.0.1 — 2018-08-15
- 1.0.0 — 2018-08-10

## README

# setaccesscontrolheaders

Use to set CORS headers to allow access from a set domain, or from localhost
if the local flag is set to true

## Usage

Install using:

```bash
npm install @neil188/setaccesscontrol
```

Then in your code import `accessControl`, then intialise by setting defaultOrigin
and allowLocal parameters

```js
const { accessControl } = require('@neil188/setaccesscontrol');

const setAccessControl = accessControl('http://default.com', true)
```

now in your request function you can call your setAccessControl function with
the response object and the request origin:

```js
exports.yourapi = async (req, res) => {

    // set CORS headers
    setAccessControl(res, req.get('origin'));
```

## LICENSE

MIT

---
_Source: https://npm.io/package/@neil188/setaccesscontrol · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
