Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
createProxyMiddleware: pathRewrite no funciona

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)); });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!