Skip to content

shapeshed/connect-force-domain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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);

About

Connect Middleware to force visitors onto a single domain

Resources

License

Stars

Watchers

Forks

Packages

No packages published