Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Connect Middleware to force visitors onto a single domain
JavaScript
Tree: f23d27a558

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
LICENSE
README.md
package.json

README.md

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);
Something went wrong with that request. Please try again.