connect-force-domain

Connect Middleware to force visitors onto a single domain

npm install connect-force-domain
7 downloads in the last week
34 downloads in the last month

Connect Force Domain

Build Status

Inspired by Rack::ForceDomain it directs all traffic to a single domain with a 301 redirect.

This is useful where you are hosting your node site with a PaaS provide like Joyent or Nodester and want to ensure all visitors are on the same domain.

Installation

via npm

npm install connect-force-domain

Usage

For connect

var connect = require('connect'),
    http = require('http'),
    forceDomain = require('connect-force-domain');

var app = connect()
  .use(forceDomain('shapeshed.com'))

http.Server(app).listen(3000);

For express

var express = require('express'),
    forceDomain = require('connect-force-domain');

var app = module.exports = express.createServer();

app.configure(function(){
  app.use(forceDomain('shapeshed.com');
});

app.listen(3000);
npm loves you