So i found the answer from another question.
Node.js: 301 redirect non-www without express
Sorry for not searching before
app.get ('/*', function (req, res, next){
if (!req.headers.host.match(/^www\./)){
res.writeHead (301, {'Location': 'http://mysite.com'});
}else{
return next();
}
});