express-one-hostname
v1.0.0
Published
Ensure your site is only served from the correct hostname
Downloads
9
Maintainers
Readme
express-one-hostname is a very small express middleware that ensures your cloud-hosted website only responds to one hostname.
It ensures that cloud hostnames like your-app-1234.some-cloud-provider.com
are not indexed by search engines.
It requires you set an ALLOWED_HOSTNAME
environment variable.
Installation
$ npm install express-one-hostname
Usage
// This will throw an error if ALLOWED_HOSTNAME is not set
const oneHostname = require('express-one-hostname')
app.use(oneHostname)
// This uses one-hostname only if ALLOWED_HOSTNAME is set
if (process.env.ALLOWED_HOSTNAME) {
const oneHostname = require('express-one-hostname')
app.use(oneHostname)
}
Running tests
Install dependencies:
$ npm install
Run tests:
$ npm test
License
MIT