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

Axios Post call retruning 502 proxy error only in production where as request to server is happening and success response from java backend rest api code. axios version is 0.19.0 . #2937

Closed
sirishasvi opened this issue Apr 30, 2020 · 3 comments

Comments

@sirishasvi
Copy link

sirishasvi commented Apr 30, 2020


Can anyone help, as i couldn't recreate this issue to check why this is happening.
I was using axios for calling rest api in my react application, I couldn't find any issue while developing and in uat , but when the code went live , in production always axios one post call is getting 502 proxy error but the same request was made to rest service and in backend everything is success. So , backend is success but user is seeing unsuccess page as it is getting 502 error.

Everything network and load balancers couldn't find any issue.

Example Code

this.postapi().then(function (response) {
//doing something

                    });

postapi() {
return axios.post('/postapi', {

                    // request data
        }
    }).catch(function (error) {
    	console.error(error);
        if(error.response.status === 500 ){
        	//error page redirect 
        }else{
        	 //unsuccess page redirect
        }

    });

}
from above code , always the api call is being done and success in rest service, but getting 502 proxy error and going to catch block and showing unsuccess page

This behaviour is only happening in production

Environment:

  • Axios Version [e.g. 0.19.0]
  • Browser [e.g. Chrome, Safari]
  • React 16.9.0
@sirishasvi sirishasvi changed the title Axios Post call retruning 502 proxy error only in production where as request is server is happening and success response from java backend rest api code. axios version is 0.19.0 . Axios Post call retruning 502 proxy error only in production where as request to server is happening and success response from java backend rest api code. axios version is 0.19.0 . Apr 30, 2020
@anixon604
Copy link

I am having the same issue. Using a react webview to axios get/post to a client.jar running in the dockerized coder-server instance.

The problem is that the request is being mapped to the local machine's hostname. When I run the client.jar locally from the machine accessing code-server the webview picks up the service running through localhost:XXXX.

Is there a way to force axios to stay relative to the docker-container when using a vscode webview?

@sirishasvi

@sirishasvi
Copy link
Author

I was wrong from starting to check the issue , i got 502 proxy error from client side because of time out issue in my apache sever configuration. increasing it fixed the issue.

@anixon604
In your case , you can try to manage the localhost url using environment variables for all regions .
So based on region, u can pick the particular configuration url.

hope it helps you.

@bharath-9
Copy link

I was wrong from starting to check the issue , i got 502 proxy error from client side because of time out issue in my apache sever configuration. increasing it fixed the issue.

Can you please tell how to do that ... change timeout in apache?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants