I am following a youtube tutorial:
CodePudding user response:
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
})
CodePudding user response:
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.