Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically creating subdomains on Heroku with nodeJS?

Is it possible to dynamically add subdomain names to a custom domain that is pointing to your heroku app?

For example, you're creating an app that allows users to create their own pages. Let's say www.example.com is pointing to your heroku app and a user named John makes a page and your app creates john.example.com that has johns content.

For node, can you do this through routing in express?

like image 683
ianfajardo Avatar asked Mar 02 '15 21:03

ianfajardo


1 Answers

Yes. You can indeed dynamically add domains to your Heroku app using the Heroku Platform API. Here's a link to the exact bit you need: https://devcenter.heroku.com/articles/platform-api-reference#domain

You can then read in the domain data via the node request object (req.url, I believe).

like image 114
rdegges Avatar answered Nov 15 '22 09:11

rdegges