node.js - Express.js vhost subdomain set up -


trying set connect's vhost middleware. love help.

i've got normal express.js app, node_modules, public, views , routes directories. i've added directory next holds express.js app.

i've added line top level app (tedxgramercy):

app.use(express.vhost('chatter.tedxgramercy.com', require('./chatter/app.js').app)); 

and line chatter app:

var app = exports.app = express(); 

the chatter app calls listen on port 8000, main (top level) app calls listen on port 3000. don't know if that's right.

when launch app (node app) runs fine , can access both apps on localhost:3000 , localhost:8000 respectively, when deploy server, subdomain http://chatter.tedxgramercy.com doesn't work.

any pointers? have change dns point other port or something?

it's simple, tricky setup.

first, main app.js:

var vhost = require('vhost');  app.use(vhost('chatter.tedxgramercy.com', require('./chatter/app').app)) app.use(router); 

i included router make clear critical used after configuring virtual hosts.

then, in chatter/app.js:

var express = require('express'); var app = express(); var path = require('path');  app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade');  var router = express.router();  router.get('/', function(req, res, next) {   res.render('index'); });  app.use(router);  exports.app = app; 

this bare minimum setup render jade template in sub app. notice app exported, no server started since main app server.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -