typescript + react16 + create-re

2019-05-23  本文已影响0人  风之伤_3eed

需要在项目的src目录下新建setupProxy.js文件
在文件中写入

// @ts-ignore 

const proxy = require('http-proxy-middleware');

module.exports = function(app) {
  app.use(proxy('/souche/api', { 
       target: 'http://192.168.50.197:8080' ,
       secure: false,
       changeOrigin: true,
      //  pathRewrite: {
      //   "^/souche/api": "/"
      //  }
    }));
};

// @ts-ignore
不写// @ts-ignoretypescript会报错

上一篇 下一篇

猜你喜欢

热点阅读