1

Im trying to set up my app with an HTTPS connection. After setting it up, Express stop routing requests that were coming in.

var path = require('path');
var express = require('express');
var https = require('https');
var fs = require('fs');

var options = {
  key: fs.readFileSync('ssl-key.pem'),
  cert: fs.readFileSync('ssl-cert.pem')
}

var app = express();
var port = process.env.PORT || 3000;

https.createServer(options, app).listen(port, function() {
  console.log('listening on port ' + port);
});

app.get('*', function(req, res) {
  console.log('test');
  res.send('hello world')
});

I keep getting ERR_EMPTY_RESPONSE

Does anyone know why this is?

Thank you for your time!

Reagan Cuthbertson
  • 330
  • 1
  • 2
  • 9

1 Answers1

0

The issue comes, because you use http://127.0.0.1:3000/ or (http://127.0.0.1:3000/), but you need to use https protocol (https://localhost:3000/) certificate for it, to make node.js catch this request

O. Borcuhin
  • 234
  • 2
  • 5