Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/john-doherty/express-set-domain
Force an express app to use a particular domain
https://github.com/john-doherty/express-set-domain
express nodejs seo
Last synced: about 1 month ago
JSON representation
Force an express app to use a particular domain
- Host: GitHub
- URL: https://github.com/john-doherty/express-set-domain
- Owner: john-doherty
- License: mit
- Created: 2020-08-07T15:33:19.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-27T10:06:59.000Z (almost 3 years ago)
- Last Synced: 2024-10-10T01:38:44.309Z (3 months ago)
- Topics: express, nodejs, seo
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# express-set-domain
Force an express app to use a particular domain by 301 redirecting none matching requests.
## Install
```bash
npm install --save express-set-domain
```## Usage
Add to your express application before all other routes.
```js
var express = require('express');
var app = express();
var setDomain = require('express-set-domain');// add middleware to force requests to orcascan.com
app.use(setDomain('orcascan.com'));// typical route
app.get('/docs/integrations/scan-barcodes-into-microsoft-excel', function(req, res) {
res.send('How to scan barcodes into spreadsheets!');
});
```Based on the above example, a request to:
http://www.orcascan.com/docs/integrations/scan-barcodes-into-microsoft-excel
would be 301 redirected to:
http://orcascan.com/docs/integrations/scan-barcodes-into-microsoft-excel
without having to list every potential incoming domain name.
## Contributing
Feel free to contribute, either by [raising an issue](https://github.com/john-doherty/express-set-domain/issues) or:
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -m 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request## Star the repo
If you find this useful please star the repo, it helps us prioritize which open source bugs to fix :raised_hands:
## History
For change-log, check [releases](https://github.com/john-doherty/express-set-domain/releases).
## License
Licensed under [MIT License](LICENSE) © [John Doherty](https://twitter.com/mrjohndoherty)