To fix "Cannot GET /" error with Connect on Node.js, we use the connect.static
method.
For instance, we write
const connect = require("connect");
const app = connect().use(connect.static(__dirname + "/public"));
app.listen(8180);
to call connect.static
to expose the /public folder as a static files folder.
And then we call use
to add the returned middleware to the app
.
Then we can see the files in the folder when we go to /