'I am using http-proxy-middleware in react js to fetch third party api this is working on localhost but not able to fetch for build production

setupProxy.js code is as follows

const { createProxyMiddleware } = require("http-proxy-middleware");
module.exports = function (app) {
  app.use(
    "/api",
    createProxyMiddleware({
      target: "http://www.postalpincode.in",
      changeOrigin: true,
    })
  );
};

Axios API call is as follows I send pincode in payload while calling

function getForm(action) {
  const url = "/api/pincode/" + action.payload;
  //const url = "http://www.postalpincode.in/api/pincode/462002";
  return axios({
    url: url,
    method: "get",
  });
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source