What is the best way to do this?
I’d like to redirect all requests from www.example.com to example.com
*.example.com to example.com would be ideal
I would think some type of middleware. I still hate this, because it seems so inelegant and slightly wasteful, but I think my only option is to do this server-side.
Since Express 3 doesn’t use its own HTTP server (instead you pass your app to
http.createServer), it doesn’t know what port it’s running on unless you tell it. That said, you can do basically what you want to do with the following:You could export this in a module and wrap it in a generator that takes a port: