# subdomain

> Node.js Express Subdomain Middleware.

Latest version **1.2.0** (published 2014-08-07) · 0 weekly downloads

## Install

```sh
npm install subdomain
pnpm add subdomain
yarn add subdomain
bun add subdomain
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2014-08-07 |
| First published | 2012-05-01 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.x |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 68 |
| Author | Edward Hotchkiss |
| Maintainers | edwardhotchkiss |
| Keywords | express, subdomain, middleware, domain |

## Links

- npm: https://www.npmjs.com/package/subdomain
- Repository: https://github.com/edwardhotchkiss/subdomain
- Homepage: http://github.com/edwardhotchkiss/subdomain
- Issues: https://github.com/edwardhotchkiss/subdomain/issues
- npm.io page: https://npm.io/package/subdomain

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2014-08-07
- 1.1.0 — 2014-07-31
- 1.0.0 — 2014-06-30
- 0.2.0 — 2014-04-30
- 0.1.0 — 2012-07-08
- 0.0.3 — 2012-05-01

## README

# subdomain [![Git Tip](http://img.shields.io/gittip/edwardhotchkiss.svg)](https://www.gittip.com/edwardhotchkiss/) 

> Node.js Express Subdomain Middleware.

I thought that this was a pretty sweet project [express-subdomain-handler](https://github.com/WilsonPage/express-subdomain-handler) but I wanted it crafted a bit differently for my purposes and the ability to force HTTPS and removal of the unneccessary 'www' prefix. Thanks for the inspiration @WilsonPage

#### /etc/hosts

```bash
127.0.0.1 localhost
127.0.0.1 blog.localhost
127.0.0.1 writing.localhost
```

#### server

```javascript
/**
 *
 * @example basic
 *
 * @description limited example
 * $ npm install express
 *
 */

var app
  , express = require('express')
  , subdomain = require('../lib/subdomain');

app = express();

app.use(subdomain({ base : 'localhost', removeWWW : true }));

app.get('/subdomain/blog/', function(request, response) {
  response.end('BLOG.LOCALHOST: "/"');
});

app.get('/', function(request, response) {
  response.end('LOCALHOST: "/"');
});

app.get('/hello', function(request, response) {
  response.end('LOCALHOST: "/hello"');
});

app.listen(8000, function() {
  console.log('> listening on port 8000');
});
```

### available options

  * `base` - Required, the base domain name i.e. 'localhost'
  * `removeWWW` - Defaults to `false`
  * `ignoreWWW` - Defaults to `false`
  * `prefix` - Defaults to 'subdomain'
  * `debug` - Defaults to `false`


[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/edwardhotchkiss/subdomain/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

---
_Source: https://npm.io/package/subdomain · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
