# hapi-allow-cors-headers

> hapi extension to enable CORS

Latest version **0.0.1** (published 2018-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install hapi-allow-cors-headers
pnpm add hapi-allow-cors-headers
yarn add hapi-allow-cors-headers
bun add hapi-allow-cors-headers
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2018-07-23 |
| First published | 2018-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 28 |
| Author | Gregor Martynus |
| Maintainers | marc-d |
| Keywords | hapi, cors, extension |

## Links

- npm: https://www.npmjs.com/package/hapi-allow-cors-headers
- Repository: https://github.com/gr2m/hapi-cors-headers
- Homepage: https://github.com/gr2m/hapi-cors-headers#readme
- Issues: https://github.com/gr2m/hapi-cors-headers/issues
- npm.io page: https://npm.io/package/hapi-allow-cors-headers

## Recent versions

- 0.0.1 (latest) — 2018-07-23

## README

# hapi-cors-headers

> hapi extension to enable CORS

[![Build Status](https://travis-ci.org/gr2m/hapi-cors-headers.svg?branch=master)](https://travis-ci.org/gr2m/hapi-cors-headers)
[![Coverage Status](https://coveralls.io/repos/gr2m/hapi-cors-headers/badge.svg?branch=master)](https://coveralls.io/r/gr2m/hapi-cors-headers?branch=master)
[![Greenkeeper badge](https://badges.greenkeeper.io/gr2m/hapi-cors-headers.svg)](https://greenkeeper.io/)

Enables [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS) on
all server response, securely from all origins, with `access-control-allow-credentials: true`.

## Example

### Hapi v17
```js
const Hapi = require('hapi');
const corsHeaders = require('hapi-cors-headers');

const server = Hapi.Server({ port: 3000 });

const provision = async () => {
    await server.register(corsHeaders);
    ...
    await server.start();
};

provision();
```

### Hapi v16

```js
const Hapi = require('hapi');
const corsHeaders = require('hapi-cors-headers');

const server = new Hapi.Server();
// setup routes etc ...

server.ext('onPreResponse', corsHeaders);
```

## Install

### Hapi v17

```bash
npm install --save hapi-cors-headers@^2.x.x
```

### Hapi v16

```bash
npm install --save hapi-cors-headers@^1.x.x
```

## Test

[![devDependency Status](https://david-dm.org/gr2m/hapi-cors-headers/dev-status.svg)](https://david-dm.org/gr2m/hapi-cors-headers#info=devDependencies)

```bash
npm test
```

## License

[MIT](LICENSE.md)

---
_Source: https://npm.io/package/hapi-allow-cors-headers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
