title: Axios get request works only when I provide the full path of the server
body: <p>I have an eCommerce project with backend built using Node.JS and express and front end using React. I connected the React frontend to the backend by providing the server address as a proxy in the package.json file present in the React folder.</p>
  <p>There are multiple components in the client side that uses Axios to fetch data from the server. The problem is in some components, the axios get request works properly when I just mention the relative path of the server route. But in other components, the request fails when I give the relative path and works only when I provide the full path.</p>
  <p>Below is a component that fetches the product list from the server and it works with just the relative path being provided.</p>
  <pre><code>componentDidMount() {
          axios.get('api/admin/getproducts')
          .then((res) =&gt; {
              this.setState({ products: res.data, loading: false })
          })
          .catch(err =&gt; {
              console.log(err)
          }) 
      }
  </code></pre>
  <p>Below is another component where when I just mention the relative path to get list of orders, the request fails with 404 (Not Found) error.</p>
  <pre><code>componentDidMount() {
          axios.get('api/user/getorder', {
              headers: {
                  &quot;auth-token&quot;: this.context.token
              }
          })
          .then((res) =&gt; {
              this.setState({orders: res.data, loading: false});
          })
          .catch((err) =&gt; {
              console.log(err)
          })
      }
  </code></pre>
  <p>Below is the error that I get when I just mention the relative path
  <a href="https://i.stack.imgur.com/o6DKU.png" rel="nofollow noreferrer">404 error that I get</a></p>
  <p>But when I mention the full path of the route including the server address in the get request, the request succeeds and responds with the data. So the below request succeeds where I mention the full path</p>
  <pre><code>axios.get('http://127.0.0.1:5000/api/user/getorder', {
              headers: {
                  &quot;auth-token&quot;: this.context.token
              }
          })  
  </code></pre>
  <p>I am not sure what is the problem here and why it does not work the way it is supposed to. Can anyone please let me know if I am missing anything either in the server side code or in the React code. I extensively searched the internet to find a solution but I could not find one.</p>
  <p>Here is my full code (both backend and frontend) =&gt; <a href="https://github.com/sundarboss/Ecommerce" rel="nofollow noreferrer">https://github.com/sundarboss/Ecommerce</a></p>