1.0.0 • Published 6 years ago

hapi-subdomain v1.0.0

Weekly downloads
1
License
GPL
Repository
github
Last release
6 years ago

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.

1.0.0

6 years ago

0.2.0

9 years ago

0.1.0

9 years ago