Neanderthals Programming Machines

npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

hapi-subdomain

1.0.0 • Public • Published

Hapi-subdomain

This is a simple plugin for using subdomains with Hapi.js, as is typical in multi-tenant applications. For example, if you give each user their own profile page at username.example.com, this plugin can invisibly redirect those urls to example.com/users/username, making configuring your routes much easier.

Once the plugin is installed, it gets added to your:

server.register([{
  register: require('hapi-subdomain'),
  options: {
    exclude: ['www', 'api', 'mail'],
    destination: '/tenant'
  }
  }], function(err) {
    if (err) console.log(err)
    });

exclude is an array of subdomains to ignore. destination is the path to prepend the subdomain to.

Only the first subdomain is detected by the regex, and any route with no subdomain (http://example.com) is ignored.

Feedback and pull requests happily accepted.

install

npm i hapi-subdomain

Downloadsweekly downloads

11

version

1.0.0

license

GPL

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability