Skip to content
This repository was archived by the owner on Apr 26, 2019. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = addCorsHeaders

function addCorsHeaders (request, reply) {
function addCorsHeaders (request, h) {
if (!request.headers.origin) {
return reply.continue()
return h.continue
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you check here if h.continue is a function and if it is, return h.continue(), otherwise return h.continue?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are both functions.
The Hapi team, made the call different. The plugins that works on 17+ wont work on earlier versions. So most of the plugins have a break change version. Like 1.0 works with 16- 2.0 17+

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, got it. It’s fine, I can release a breaking version. Can you check that the tests pass? Please compare with the other open PRs 🙏 Thanks!

}

// depending on whether we have a boom or not,
Expand All @@ -12,7 +12,7 @@ function addCorsHeaders (request, reply) {
response.headers['access-control-allow-origin'] = request.headers.origin
response.headers['access-control-allow-credentials'] = 'true'
if (request.method !== 'options') {
return reply.continue()
return h.continue
}

response.statusCode = 200
Expand All @@ -26,5 +26,5 @@ function addCorsHeaders (request, reply) {
response.headers['access-control-allow-methods'] = request.headers['access-control-request-method']
}

reply.continue()
return h.continue
}