0.0.1 • Published 6 years ago

hapi-allow-cors-headers v0.0.1

Weekly downloads
15
License
MIT
Repository
github
Last release
6 years ago

hapi-cors-headers

hapi extension to enable CORS

Build Status Coverage Status Greenkeeper badge

Enables CORS on all server response, securely from all origins, with access-control-allow-credentials: true.

Example

Hapi v17

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

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

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

Hapi v16

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

Test

devDependency Status

npm test

License

MIT