Axios post with proxy on create-react-app hosting server doesn’t work

I have following line in my package.json (react app)

"proxy": ""

I’m requesting data using REST-API call'/user_data', { //
    .then((response) => { 
    .catch((error) => {


Above code works fine if I use it in my local system, But if I build a project and upload into hosting server proxy doesn’t work.

Anyone know the solution? I have checked in github also but not found proper solution.


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I think you should define your proxy in the axios config, if it should be applied globally for every requests, you can use this code to define the Global axios default

import axios from 'axios'; = ""
axios.defaults.proxy.port = ...
axios.defaults.proxy.auth.username = ...
axios.defaults.proxy.auth.password = ...

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x