How to check the HOST using ExpressJS?

Viewed 25380

I have to check the HOST of the http request, if it's equal to example.com or www.example.com, I have to do a 301 redirect.

How can I do this using Node.js and Express Web Framework?

5 Answers

Today for me it's req.host, req.hostname and req.headers.host - I'm going with req.host though.

Related