I am following a youtube tutorial:https://www.youtube.com/watch?v=ngc9gnGgUdA&t=1125s. In 18:25. "THIS WORK!" should be printed out on the localhost:5000 page, but I am not able to see it. Anyone can help?
From what I can see (as part of the first image is cut off), the problem is probably that you forgot call app.listen, which tells express to listen on port 5000.
app.listen(process.env.PORT, () => {
// callback when server is up
})
It could be a CORS issue. Please try this
app.use(cors({
origin: '*',
}));
That is because the same origin will always be allowed. If you need to allow requests from everywhere, that should be manually configurated. The code above basically will set the header Access-Control-Allow-Origin: * to do so.
This article explains in-depth about this. Even if it happens to be not applicable here, it's worth reading.