sails-hook-allowed-hosts
Sails hook to ensure that only requests made from authorized hosts/IP addresses are allowed. Inspired by the
ALLOWED_HOSTS
setting in Django.
Installation
npm install sails-hook-allowed-hosts --save
Usage
Install the hook and add configuration for it
moduleexportsallowedhosts = allowedHosts: array with strings or regular expression matches for allowed hosts // default [/.*/] skipEnvs: array listing environments for which to skip host checking // default ['test', 'development'];
Optionally you can customize the response in case the host doesn't match. By default a 400 badRequest is sent
moduleexportsallowedhosts = allowedHosts: /test\.com/ skipEnvs: 'test' 'development' { return res; };