To fix Error: Cannot GET / witn Node Express, we add render a template or expose a static folder.
For instance, we write
app.use(express.static(__dirname + "/public"));
app.get("/", (req, res) => {
res.render("index.ejs");
});
to call app.use
with the middleware returned by express.static
to expose the /public folder as a static files folder.
We also add a get / route to render the index.ejs template.