krysalead / hapi-cors-headers

hapi extension to enable CORS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

var Hapi = require('hapi');
const corsHeaders = require('hapi-cors-headers')('localhost:8888', logger);

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

server.ext('onPreResponse', corsHeaders);

logger is option if not specified it will be console. The first arguments tells to cors-header to allow only on localhost:8888

Install

npm install --save hapi-cors-headers

Test

devDependency Status

npm test

License

MIT

About

hapi extension to enable CORS

License:MIT License


Languages

Language:JavaScript 100.0%