Skip to content

Error: Cannot GET / #325

Answered by IamLizu
Bhaney44 asked this question in Q&A
Sep 15, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hi @Bhaney44 👋

I think you are actually missing a root route. As you can see, / after http://localhost:3000 is actually the endpoint being requested when you type in http://localhost:3000/ in your browser.

So, simply add a handler for route like,

app.get('/', (req, res) => {
  res.send('Welcome to the API server!');
});

Also, you do not need to specify cors() middleware in every route since you are already doing it in app.use which will add that middleware for every route.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Bhaney44
Comment options

Answer selected by IamLizu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #324 on September 15, 2024 09:28.