我正在使用 http-proxy-middleware 来获取 api 但无法获取构建生产

I am using http-proxy-middleware to fetch api but not able to fetch for build production

Image of setupProxy.js

我目前在 package.json 中使用代理,但是当我构建它时无法显示 api,请告诉我如何在构建生产中获取以及另一种方法。 我尝试了 http-proxy-middleware 但无法访问它。

error in build production

api localhost:9763

从下次开始,直接插入代码而不是图片。

const { createProxyMiddleware } = require("http-proxy-middleware");

module.exports = function (app) {
  app.use(
    "/api",
    createProxyMiddleware({
      target: "http://localhost:9763",
      changeOrigin: true,
    })
  );
};

如果您这样声明代理,所有带有“/api”的请求都将连接到端口 9763。

localhost:3000/api => localhost:9763/api

如果你使用的是axios,你可以这样使用:

axios.get('/api/getPlaylist', {
  params: {
    Playlist: 'all'
  }
})

我在 nodejs 中是这样得到的 api。

req.query;