Skip to content

Instantly share code, notes, and snippets.

@nebulou5
Created December 1, 2015 07:19
Show Gist options
  • Save nebulou5/b132e464b34fdccbdb5b to your computer and use it in GitHub Desktop.
Save nebulou5/b132e464b34fdccbdb5b to your computer and use it in GitHub Desktop.
it('returns OPTIONS response if origin header is capitalized', (done) => {
const handler = function (request, reply) {
return reply(Boom.badRequest());
};
const server = new Hapi.Server();
server.connection({ routes: { cors: true } });
server.route({ method: 'GET', path: '/', handler: handler });
server.inject({ method: 'OPTIONS', url: '/', headers: { Origin: 'http://example.com:8080/', 'access-control-request-method': 'GET' } }, (res) => {
expect(res.headers['access-control-allow-origin']).to.equal('http://example.com:8080/');
done();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment