79799324

Date: 2025-10-25 04:45:15
Score: 0.5
Natty:
Report link

You're almost there. Use the full URL in your fetch request because your backend lives on a completely different address.

So here's how your fetch request should look like:

const response = await fetch('http://localhost:5000/users', {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(body)
});

Why http://localhost:5000/users instead of /users ? Because /users will resolve to localhost:3000/users (as indicated in your error), and that address is where the frontend lives, not the backend.

As a side note, your current code would work if you'd configured a proxy to backend URL, but you probably don't need to do that.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: Rasul Navir