在用node搭建的环境中,测试一下反向代理的过程,在安装了http-proxy-middleware后,去运行,报错proxy is not a function
代码如下:
const proxy = require('http-proxy-middleware')
app.use('/api', proxy({
target: 'http://localhost:4000', changeOrigin: false
}));
查看以后这是原来老版本的写法,现在更新以后
const {createProxyMiddleware} = require('http-proxy-middleware')
app.use('/api', createProxyMiddleware({
target: 'http://localhost:4000', changeOrigin: false
}));
更多的详细用法可参考下方
参考:[https://www.npmjs.com/package/http-proxy-middleware]