How to make a POST request from react to node backend when they're on different ports?

I’m trying to make a beginner application. My goal is to have a site where you can post things and they’ll be saved into the database, pretty basic.

Although, I’m getting pretty confused. So, I make a get request to display the react page on port 3000, but I’m also trying to make a POST request to my node backend on port 5000. How do I do this?

Sorry if this is vague, I’m just really confused lol.
That’s exactly what I did :(, including the proxy, it still says 404 because it’s searching port 3000 for /api/req (the express file) for some reason.

Here’s the express:

router.post('/api/req',(req,res)=>{
    const newPost = new Post({
        title: req.body.title,
        description: req.body.description
    })

    newPost.save().then(()=>{
        console.log('Item added to database!')
    });
    
})

And here’s the axios request:

axios({
      method: 'post',
      url: '/api/req',
      data: {
        title: this.state.title
      },
      validateStatus: (status) => {
        return true; 
      },
    }).catch(error => {
        console.log(error);
    }).then(response => {
        console.log(response);
    });
I changed the url of the axious request to http://localhost:5000/routes/api/req and it gives me a 404(not found).

I also made the proxy to localhost:5000.

In your router.post you reference /api/req, so why are you trying to go to http://localhost:5000/routes/api/req? Try going to http://localhost:5000/api/req

I already put localhost:5000 in the proxy in the package.json though. It should just search that automatically I thought.

you have to enable CORS in the backend to allow connection outside the domain otherwise your backend will not allow the request.

If its not CORS , please paste the error message here + code or repo so that people can understand your problem better.

edit: i looked at your comments and you mentioned u have 404 not found please paste the routes and have u test the route on postman if the route is up?

It works on Postman, just not from the axios request.

Here’s the github with relevant files:https://github.com/Nibpib/MERNHELP

And the file structure is just like this:

But without the actions folder.