Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rajitgargkohls opened this issue Sep 6, 2018 · 7 comments
Projects

Comments

@rajitgargkohls
Copy link

rajitgargkohls commented Sep 6, 2018

Hi,

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
@rajitgargkohls rajitgargkohls changed the title Request failed with status code 503 while trying to get response of an api using axios Http proxy append in front of the actual URL | Request failed with status code 503 Sep 12, 2018
@akg268
Copy link

akg268 commented Nov 13, 2018

+1

@tinaboyce
Copy link

Experiencing the same issue with axios@0.18.0

@sivasankars
Copy link

+1, Same Issue :(

@erisnuts
Copy link

Any solution?

@jonathanfoster
Copy link
Contributor

Looks like PR #2562 may resolve this issue. I ran into a similar issue and was able to resolve it by explicitly configuring proxy options and setting the protocol to HTTPS.

proxy: {
  host: 'localhost'
  port: 8080,
  protocol: 'https'
}

Take a look at PR #3070 for more info.

@magicdawn
Copy link

image
in order to proxy https url, http tunnel (CONNECT method) should be used.
what axios current use: modify url to proxy + url may be buggy

case for me:
https://github.com/jeffijoe/typesync/blob/81a10e96a73a2948950513892318cc4e23ffe99c/src/type-definition-source.ts#L4
https://github.com/jeffijoe/typesync/blob/81a10e96a73a2948950513892318cc4e23ffe99c/src/type-definition-source.ts#L16

with process.env.http_proxy enabled
cause
image
image

the NO_PROXY help could help

# fish
set -x NO_PROXY 'typespublisher.blob.core.windows.net'

@jasonsaayman jasonsaayman added this to To do in v1.0.0 via automation May 15, 2021
@jasonsaayman
Copy link
Member

See #4209

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v1.0.0
  
To do
Development

No branches or pull requests

9 participants