Answer the question
In order to leave comments, you need to log in
How to properly set up an https server on nodejs?
I put up a server like this:
const http = require('http');
const https = require('https');
const fs = require('fs');
const PathToKey = './ssl/localhost-100y.key';
const PathToCert = './ssl/localhost-100y.cert';
const httpsOptions = {
key: fs.readFileSync(PathToKey),
cert: fs.readFileSync(PathToCert)
};
const app = function (req, res) {
res.writeHead(200);
res.end("hello world\n");
}
http.createServer(app).listen(8080);
https.createServer(httpsOptions, app).listen(443);
ERR_EMPTY_RESPONSE
. I don’t understand what’s the matter, I’ve already shoveled a bunch of examples.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question