Reenviaría desde /api/getUser a /getUser endpoint. Localmente funciona, pero remotamente no, remotamente envía a /api/getUser , ¿por qué?
heroku[router]: at=info method=POST path="/api/getUser" host=speechifai-poc.herokuapp.com request_id=f6f155e0-2ab0-4a6e-a0cd-354557d0fcdd fwd="58.97.222.40" dyno=web.1 connect=0ms service=1ms status=404 bytes=588 protocol=https Puedo ajustar si la orientación es local/remota configurando false / true .
if (false) { axios.defaults.baseURL = "http://localhost:3000/api/"; } else { axios.defaults.baseURL = "https://speechifai-poc.herokuapp.com/api/"; } const { createProxyMiddleware } = require("http-proxy-middleware"); module.exports = function (app) { app.use( "/api", createProxyMiddleware({ target: false ? "http://localhost:8080" : "https://speechifai-poc.herokuapp.com", changeOrigin: true, pathRewrite: { "^/api": "/", // rewrite path }, }) ); };Tengo:
"http-proxy-middleware": "^2.0.3",Y llamo aquí con axios:
axios({ method: "post", url: "getUser", data: {}, headers: { crossDomain: true }, }).then((res) => { dispatch(setGetUser(res.data)); });