Issue: I'm trying to create an HTTPS server using a self signed certificate on openssl. I am able to run the server but when I make a request to "https://localhost:3001", it hangs forever on "Sending request...".
I've tried making the request in the browser (Brave and Chrome) and in Postman, both with the same issue of loading forever. I'm not sure what I am doing wrong?
You are not using the variable app
anywhere in your code.
So your API does not have any endpoints, etc.
To fix it add second parameter to createServer with your express.js app like so:
https.createServer({
key: privateKey,
cert: certificate
}, app).listen(port);
Notice the second parameter here is app
.
Then your server will have the / endpoint and you should get results.
Note: You don't need to do return res.send("Hello World!");
.
Just doing res.send("Hello World!");
is enough.