What is the best practice to handle subdomains with nodejs and express?
Each subsomain will not be static files like index.html etc. but pure code and logic
var express = require('express'),
http = require('http');
var app = express();
app.set('port', 8080);
app.set('case sensitive routing', true);
// Catch api.localhost
app.get('/*', function(request, response){
/*
Other logic
*/
response.end('API');
});
// Catch www.localhost
app.get('/*', function(request, response){
/*
Other logic
*/
response.end('WEB');
});
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port '+app.get('port'));
});