You can add a custom middleware that sets the property for each request:
app.use(function (req, res, next) {
req.root = req.protocol + '://' + req.get('host') + "https://stackoverflow.com/";
next();
});
Using req.get to obtain the Host header, which should include the port if it was needed.
Just be sure to add it before:
app.use(app.router);