<p>API Usage in <code>getInitialsProps</code> but throwing error <code>error connect ECONNREFUSED 127.0.0.1:443</code>
full url: <code>http://ingress-nginx-controller.ingress-nginx.svc.cluster.local/api/users/currentuser</code></p>
<p>But if I called <code>https://ticketing.dev/api/users/currentuser</code> directly from the browser then it returned the expected response.</p>
<pre><code>PS C:\Users\sajee&gt; kubectl get namespace
NAME              STATUS   AGE
default           Active   3d16h
ingress-nginx     Active   3d15h
kube-node-lease   Active   3d16h
kube-public       Active   3d16h
kube-system       Active   3d16h
PS C:\Users\sajee&gt; kubectl get services -n ingress-nginx
NAME                                 TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
ingress-nginx-controller             LoadBalancer   10.96.242.223    localhost     80:31220/TCP,443:30164/TCP   3d15h
ingress-nginx-controller-admission   ClusterIP      10.109.183.213   &lt;none&gt;        443/TCP                      3d15h
PS C:\Users\sajee&gt;
</code></pre>

Sajeeb M Ahamed
<pre><code>  Home.getInitialProps = async ({ req }) =&gt; {
      if (typeof window === &quot;undefined&quot;) {
        const { data } = await axios.get(&quot;http://ingress-nginx-controller.ingress-nginx.svc.cluster.local/api/users/currentuser&quot;,
        {
          headers: req.headers,
        }
     );

     return data;
      } else {
      // we are on the browser!

       const { data } = await axios.get(&quot;/api/users/currentuser&quot;);

       return data;
      }
      return {};
   };
</code></pre>
<p>Try to pass with req props and sent headers with req.headers.
Right now you are working with auth service and client service.your ingress nginx server try to find route in client service initially there are no routes or api endpoint not found.if you hard refresh your browser then the request goes to your auth service and fetch data.</p>
