ExpressJS SSL on one domain only

ExpressJS SSL on one domain only

Problem

I’m using ExpressJS. My app is a https server which also contains a vhost.

app.use(express.vhost('api.example.com', require('./lib/subdomains/api').app));

Because my SSL certificate is for the root domain only, my api.example.com domain now fails to load the routes it’s been given.

How can I only use SSL on my root domain and not on my other? I need to be able to share the app configuration between the domains, but not the SSL certificate.

Problem courtesy of: James

Solution

Doh. I hadn’t changed my NODE_ENV so the vhost was setup incorrectly in the live environment.

Solution courtesy of: James

Discussion

Leave a Reply

Your email address will not be published. Required fields are marked *