I'm trying to make a simple hello world kind of server using Express. Here goes my code:
const express = require("express");
const app = express();
app.get("/",function(request, response){//what to do when someone make get request to the homepage or route
console.log(request);
response.send("hello");
});
app.listen(3000, function(){
console.log("server is listening at port 3000");
});
When I run the program I see this at the command prompt:
server is listening at port 3000
But when I'm accessing it through a browser i.e. https://localhost:3000
, I'm getting an error:
This site can’t provide a secure connection localhost sent an invalid response. Try running Windows Network Diagnostics. ERR_SSL_PROTOCOL_ERROR
I expect the browser to see hello
as per my method, above, response.send("hello")
You need to access it through the HTTP
protocol instead. try to connect to http://localhost:3000
instead of https://localhost:3000
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With