hapi-allow-cors-headers

0.0.1 • Public • Published

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

/hapi-allow-cors-headers/

    Package Sidebar

    Install

    npm i hapi-allow-cors-headers

    Weekly Downloads

    0

    Version

    0.0.1

    License

    MIT

    Unpacked Size

    8.52 kB

    Total Files

    6

    Last publish

    Collaborators

    • marc-d