how to proxy to backend server on certain path?

♀尐吖头ヾ 提交于 2019-12-05 02:11:49
  1. Check Webpack Dev Server documentation, you need to provide object with target property.

  2. http-proxy-middleware documentation shows usage of patterns for matching.

In conclusion, I would try this:

proxy: {
  '/service/**': { target: 'http://localhost:8080' }
}

Make sure you are handling promises correctly for the API calls. I was facing the same issue, wherein the client server was handling all the of the API calls instead of returning a 404 error and proxy taking over.

fetch("/api/list")
    .then(res => res.json())
    .then(data => {
      // handle the data
      })
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!