p-meier / hapi-api-version

An API versioning plugin for hapi.
Apache License 2.0
74 stars 26 forks source link

Prevent 500 errors on malformed CORS access-control-request-method headers #24

Closed timcosta closed 5 years ago

timcosta commented 5 years ago

With the current implementation an OPTIONS request with a missing or empty access-control-request-method header triggers a 500 error due to https://github.com/hapijs/hapi/blob/f02cdf14560a22c27dc0b59f3efa93dcf06b3ffa/lib/server.js#L345.

This PR causes hapi-api-version to short circuit the call to server.match and responds with a 400.