美文网首页
typescript + react16 + create-re

typescript + react16 + create-re

作者: 风之伤_3eed | 来源:发表于2019-05-23 16:10 被阅读0次

需要在项目的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会报错

相关文章

网友评论

      本文标题:typescript + react16 + create-re

      本文链接:https://www.haomeiwen.com/subject/pblbzqtx.html