Http proxy append in front of the actual URL | Request failed with status code 503 axios

Viewed 917

I am using axios to fetch response of one of the Api http://xxxxxxxxxxxxxxxxxx.com/actuator/health, I am successfully able to fetch its value from my React Client side code, but when I am setting express endpoint for this at server side and calling below endpoint from the browser

```

app.get('/health', function (req, res) {
var url = serviceUrl + '/actuator/health';
axios.get(url)
    .then((response) => {
      const data = response.data;
      console.log(data);
      res.json(data);
    })
    .catch((err) => {
      console.log(err);
    })
});

``` then I am getting below error

Error:

Request failed with status code 503 statusText: 'DNS Fail', host: 'proxy-gcp-central.xxxx.com', responseUrl: 'http://proxy-gcp-central.xxxx.com/http://xxxxxxxxxxxxxxxxxx.com/actuator/health' _currentUrl: 'http://proxy-gcp-central.xxxx.com/http://xxxxxxxxxxxxxxxxxx.com/actuator/health'

Where http://proxy-gcp-central.xxxx.com/ is append in front of the actual url => hence it is failing

I am getting this issue on cloud environment, I am able to fix this issue on my local by providing proxy information along with url in axios.get function above(as on local I am using proxy server to access this URL), but on cloud we are able to access this directly without use of proxy server, so for cloud, we cannot set this proxy information in this code.

I have tried this with many other node modules like http, request, request-promise, but still I am getting the same issue.

I have also tried to set Access-Control-Allow-Origin, Access-Control-Allow-Methods, Access-Control-Allow-Headers in headers as well as in app.use, but none of them resolve my issue.

Context
  • axios version: e.g.: v0.17.1
  • Environment: e.g.: node v8.11.3, npm v6.2.0, chrome 68.0.3440.106 (Official Build) (64-bit), windows 7
0 Answers
Related