title: React not using proxy url to post the data to the server
body: <p>For the front end, I have a code in react js and I am trying to post the JSON data as a query from react to express.
  Express server is running on port <code>5000</code></p>
  <pre><code>  const [ search, setSearch ] = useState(&quot;&quot;);
  
    const updatesearches = async () =&gt; {
      const result = await fetch(&quot;/api/searchposts&quot;,{
        method: &quot;POST&quot;,
        body: JSON.stringify({search}),
        headers: {
          &quot;Content-Type&quot; : &quot;application/json&quot;,
        }
      });
      const res = await result.json();
      console.log(res);
    }
  
    useEffect(() =&gt; {
      updatesearches();
    },[search])
  </code></pre>
  <p>The server is working perfectly which I already have tested on the postman. For the back end here is the code of the exrpess controller:</p>
  <pre><code>const { PostModel }  = require(&quot;../models&quot;);
  
  const getsearchposts = async (req , res) =&gt; {
      const result = await PostModel.find({title : &quot;Ukraine war: Gruesome evidence points to war crimes on road outside Kyiv&quot;});
      res.send(result);
  }
  module.exports = { getsearchposts };
  </code></pre>
  <p>In the <code>postrouters.js</code> file</p>
  <pre><code>const express = require(&quot;express&quot;);
  const router = express.Router();
  const { getsearchposts } = require(&quot;../controllers/getsearchposts&quot;);
  
  router.post(&quot;/api/searchposts&quot;, getsearchposts );
  
  module.exports = router;
  </code></pre>
  <p>And in the react package.json file i have used <code>&quot;proxy&quot; : &quot;http://localhost:5000&quot;,</code></p>
  <p>The output is printed on the browser console when i change the <code>search</code> state is below</p>
  <pre><code>POST http://localhost:3000/api/searchposts net::ERR_INTERNET_DISCONNECTED
  Sidebar.js:9          Uncaught (in promise) TypeError: Failed to fetch
      at updatesearches (Sidebar.js:9:1)
      at Sidebar.js:22:1
      at invokePassiveEffectCreate (react-dom.development.js:23479:1)
      at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
      at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
      at invokeGuardedCallback (react-dom.development.js:4056:1)
      at flushPassiveEffectsImpl (react-dom.development.js:23566:1)
      at unstable_runWithPriority (scheduler.development.js:468:1)
      at runWithPriority$1 (react-dom.development.js:11268:1)
      at flushPassiveEffects (react-dom.development.js:23439:1)
  </code></pre>