adamhalasz/diet

Can I listen on mydomain.com and also www.mydomain.com without making 2 servers?

Closed this issue · 2 comments

Hi,

I have multiple websites hosted with Diet and I have realized only recently I can only access it using mydomain.com and not www.mydomain.com.

Here is some example code of my site currently.

var server = require('diet')
var app = server()
app.listen('http://mydomain.com/')

app.get('/', function($){
  $.end('Hello World!')
});

It only listens on mydomain.com not www.mydomain.com.

How can I get it do do this without doing (preferably):

var server = require('diet')
var app = server()
var app1 = server()
app.listen('http://mydomain.com/')
app1.listen('http://www.mydomain.com/')

app.get('/', function($){
  $.end('Hello World!')
});

app1.get('/', function($){
  $.end('Hello World!')
});

Thanks in advance.

you can call listen more then once 👍

var server = require('diet')
var app = server()
app.listen('http://mydomain.com/')
app.listen('http://www.mydomain.com/')

app.get('/', function($){
$.end('Hello World!')
});

@frank-dspeed Thanks so much!