Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/franciscop/forcedomain
Use the provided domain. Useful when managing more than one
https://github.com/franciscop/forcedomain
Last synced: 14 days ago
JSON representation
Use the provided domain. Useful when managing more than one
- Host: GitHub
- URL: https://github.com/franciscop/forcedomain
- Owner: franciscop
- License: mit
- Created: 2015-10-01T13:00:02.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-01T14:06:36.000Z (about 9 years ago)
- Last Synced: 2024-09-15T12:17:52.542Z (about 2 months ago)
- Language: JavaScript
- Size: 125 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# force-domain
A module part of the project [Clean Url](https://github.com/franciscop/cleanurl). It forces a domain, for those who manage multiple domains. Say you have the following domains:
- example.info
- example.com
- example.orgBut you want them all to use the last one, `example.org`. Easy, just point them all to the same server and let `force-domain` to take care of it. It's also useful when changing domains, since urls will be preserved: `example.info/any/folder` will redirect to `example.org/any/folder`
Use it with your middleware:
```js
// Include the repository from npm
var forcedomain = require('force-domain')({ host: "example.org" });// Allow express to use it (put this before your routes!)
app.use(notrailing);
```## Options
There are some options that can be used with the module:
- `host`: the domain that you want to use. You can also use this to force `www.`, but we don't really recommend it
- `localhost`: defaults to `true`. Allow for localhost to be excluded for development purposes.
- `permanent`: defaults to `true`.## Testing
`npm test` should do the trick to make sure everything works
## Known issues
If you are behind a proxy like in heroku, when there's a redirect from `force-domain` it will redirect to the `http` version. We recommend using `force-https` or the full `clean-url` npm modules to avoid this.