Accessing endpoint via SSH tunnel

R

Rich

Guest
I'm running a dev project on my local machine (localhost) which is trying to load data from an endpoint on a server via an SSH tunnel (a React JS SPA).

The SSH tunnel is established fine and the endpoint returns the correct data packet when run in Postman using a simple GET.

But when I try to access the data from my app (fetch and Axios tried) a 200 is returned but unfortunately always with an empty array - rather than a 1k object array.

Below are the 2 simple requests, where 'localhost:8912' is the exposed & mapped port - which works in Postman.

Fetch:

fetch("http://localhost:8912/ENDPOINT/")
.then(res => console.log(res))
.catch(err => {
console.log(err);
return null;
});


Axios:

axios
.get("http://localhost:8912/ENDPOINT/")
.then(data => console.log(data.data))
.catch(err => {
console.log(err);
return null;
});


The result is returned almost immediately within the browser but take a few seconds within Postman due to server-side calculations.

Any suggestions welcomed.

Continue reading...
 
Top