Skip to content

Parse req.headers.host into a heiarchy of domains and sub-domains populating the 'req.domains' object.

Notifications You must be signed in to change notification settings

johnhenry/connect-domains

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

#connect-domains

Parse req.headers.host into a heiarchy of domains and sub-domains populating the 'req.domains' object.

Example

var express = require('express');
var app = express();
// ...
app.use(require('connect-domains')("example.com"));
app.use(function(req,res){
    //when visiting "www.sub1.example.com"
    console.log(req.domains[0]);//#"example.com"
    console.log(req.domains[1]);//#"sub1"
    console.log(req.domains[2]);//#"www"
    console.log(req.domains).join("/");//#"example.com/sub1/www"
})
app.listen(8080);

About

Parse req.headers.host into a heiarchy of domains and sub-domains populating the 'req.domains' object.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published