Nate Nate - 1 year ago 118
Node.js Question

Node.js https does not work in Cloud9

I can create an http server and it works fine, but as soon as I try to use https instead, the server runs without errors but I cannot connect to it at all.

HTTP (working):

http.createServer(app).listen(process.env.PORT, process.env.IP);

HTTPS (not working):

var options = {
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.crt')

https.createServer(options, app).listen(process.env.PORT, process.env.IP);

There are no errors in either method, but when I use HTTPS, there is no response when visiting the webpage and the server acts like it's not even receiving a request. Is there something wrong with the port I'm using from the Cloud9 environment? I have tried for hours to figure out what the problem is but haven't made any progress, hopefully someone can help out.

Answer Source

I'm afraid HTTPS will currently not work on Cloud9, as this requires the usage of other ports that are currently not opened for security reasons. We're working on a solution for this, but this will not be available on the short term yet.

For now, I recommend using two sets of configuration for development and production environments: the development environment can then just use HTTP, and production environments can use HTTPS.

Please keep an eye on our Twitter feed and blog for updates on this!