Reputation: 15268
Looking at the docs for the latest 17.2.0 release, it seems to me that I have to add cors support to each route explicitly. However, the following does not work for me
server.route({
method: 'GET',
path: path,
handler: handler,
options: {
cors: true
}
});
And, even if it did, would really like to add cors support to all the routes in one place instead of doing it for every route separately. In the previous versions, I could do the following
server.connection({ routes: { cors: true } });
But that doesn't seem to be possible anymore. What do I do?
Upvotes: 1
Views: 1143
Reputation: 878
In hapijs 17, you initialize the connection details with the servers constructor. server.connection() is no longer available.
const server = new Hapi.Server({
host: 'localhost',
port: 3000,
routes: {cors: true}
})
Upvotes: 6