Above React16.7 version set local agent

New setupProxy.js file in the root directory of the file src content:

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

module.exports = function(app) {
  app.use(
    '/api',
    createProxyMiddleware({
      target: 'http://4*.*1*.5.**:5000',
      pathRewrite: {
        "^/api": ""
      },
      changeOrigin: true,
    })
  );
};

  You can re-run the application, do not do other processing will automatically load the file.

Guess you like

Origin www.cnblogs.com/winyh/p/12363619.html