title: Heroku double '/' problem - node js backend, 404 error
body: <p>I have deployed my backend on heroku and I have a test get request's response on <code>/</code></p>
  <pre><code>app.get('/', (req, res) =&gt; {
      res.send(&quot;Hello, World. The app is running!&quot;);
  });
  </code></pre>
  <p>On hitting the <code>/</code> end point that is <a href="https://ayush-portfolio-backend.herokuapp.com/" rel="nofollow noreferrer">https://ayush-portfolio-backend.herokuapp.com/</a>, I get the expected <code>GET</code> output.</p>
  <p>But, when from the frontend react app, I hit any <code>POST</code> endpoint, e.g.:-</p>
  <pre><code>// index.js
  app.use('api/portfolios/', (require('./routes/portfolio')));
  
  // portfolio route
  router.post('/getportfolios', async (req, res) =&gt; {...});
  </code></pre>
  <p>I am unable to get any response on the frontend.</p>
  <p>As suggested by heroku docs, when I do <code>heroku logs</code><br />
  I get the following error:-</p>
  <pre><code>2022-09-21T07:57:41.743176+00:00 heroku[router]: at=info method=OPTIONS path=&quot;//api/portfolios/getportfolios&quot; host=ayush-portfolio-backend.herokuapp.com request_id=0aff16a8-8aee-499e-a69e-4bdf8d583e6d fwd=&quot;103.164.24.154&quot; dyno=web.1 connect=0ms service=5ms status=204 bytes=312 protocol=https2022-09-21T07:57:41.808753+00:00 heroku[router]: at=info method=OPTIONS path=&quot;//api/portfolios/getportfolios&quot; host=ayush-portfolio-backend.herokuapp.com request_id=3c1974f2-522c-47b8-92d8-2f201bd0e2ab fwd=&quot;103.164.24.154&quot; dyno=web.1 connect=0ms service=1ms status=204 bytes=312 protocol=https2022-09-21T07:57:42.054955+00:00 heroku[router]: at=info method=POST path=&quot;//api/portfolios/getportfolios&quot; host=ayush-portfolio-backend.herokuapp.com request_id=6092ee53-d98d-4fa0-9fff-abd46554de56 fwd=&quot;103.164.24.154&quot; dyno=web.1 connect=0ms service=10ms status=404 bytes=445 protocol=https  
  2022-09-21T07:57:42.172808+00:00 heroku[router]: at=info method=POST path=&quot;//api/portfolios/getportfolios&quot; host=ayush-portfolio-backend.herokuapp.com request_id=cbe7b873-b4f5-4eb6-a80f-12fd1018029a fwd=&quot;103.164.24.154&quot; dyno=web.1 connect=0ms service=2ms status=404 bytes=445 protocol=https
  </code></pre>
  <p>I don't know what is causing the following error. The app works perfectly fine on the local environment, but don't know why the problem has occured.</p>
  <p>I am a beginner for heroku and I don't know much about it, also i searched the google and stackoverflow for the error but did not find any relevant solution to the problem.</p>
  <p>I just assume that the error can be because of some double / <code>//</code> creating in the path as in the error it is shown e.g. <code>path='//api/portfolios/getportfolios'</code>. So, I also tried removing the / from frontend and everywhere else trying to make it sinbgle / but this didn't solve the problem.</p>
  <p>Can someone please guide me to find the solution of the above problem.
  Thank you!</p>
  <p>////////////////EDIT////////////////<br />
  portfolio route file: <a href="https://github.com/Ayush181005/Portfolio-Backend/blob/master/routes/portfolio.js" rel="nofollow noreferrer">github</a></p>