Skip to content

Commit

Permalink
add PATCH to default cors methods, closes #1475
Browse files Browse the repository at this point in the history
  • Loading branch information
nlf committed Mar 10, 2014
1 parent 3ff34f3 commit be79511
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ exports.cors = {
'HEAD',
'POST',
'PUT',
'PATCH',
'DELETE',
'OPTIONS'
],
Expand Down

1 comment on commit be79511

@cdll
Copy link

@cdll cdll commented on be79511 Jul 19, 2024

Choose a reason for hiding this comment

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

i've found that patch method could not be matched but PATCH could be matched on the route defination.

// a client request
fetch('/path_to_patch_api', {
  method: 'PATCH',
})
// a hapi route
hapi.route([{
  method: 'patch',
  path: '/path_to_patch_api',
}])
// πŸ‘† works

// πŸ‘‡ not working
// a client request
fetch('/path_to_patch_api', {
  method: 'patch',
})
// a hapi route
hapi.route([{
  method: 'patch',
  path: '/path_to_patch_api',
}])

but both bellow works fine:

// a client request
fetch('/path_to_get_api', {
  method: 'GET',
})
// a hapi route
hapi.route([{
  method: 'get',
  path: '/path_to_get_api',
}])
// πŸ‘† works

// πŸ‘‡ works too
// a client request
fetch('/path_to_get_api', {
  method: 'get',
})
// a hapi route
hapi.route([{
  method: 'get',
  path: '/path_to_get_api',
}])

Please sign in to comment.