0.0.1 • Published 6 years ago
hapi-allow-cors-headers v0.0.1
hapi-cors-headers
hapi extension to enable CORS
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
npm test
License
0.0.1
6 years ago