0
点赞
收藏
分享

微信扫一扫

软件实例分享,台球厅收费系统电脑桌球店计时软件及灯控线路图教程

耶也夜 2024-02-19 阅读 57

http-proxy-middleware

使用npm安装

文档

点击查看

关键代码

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

module.exports = function(app) {
  app.use(
    '/api',	// api开头的地址的请求
    createProxyMiddleware({
      target: 'http://localhost:5000',	// 发向何处
      changeOrigin: true,
    })
  );
};

例如一个请求: http://localhost:5000/api/getPictures
则发送时使用: /api/getPictures
会被上面的‘/api’给检索到,则将/api.getPictures拼接http://localhost:5000然后发出。

举报

相关推荐

0 条评论