react 配置 setupProxy.js后 网页打不开,出现无法访问此网站 |
您所在的位置:网站首页 › react项目启动报错 › react 配置 setupProxy.js后 网页打不开,出现无法访问此网站 |
经搜索。发现是 "http-proxy-middleware": "^2.0.4" 版本号为高版本。 版本为低版本 的时候 const { proxy } = require('http-proxy-middleware') 低版本 的时候可以这样 : const proxy = require('http-proxy-middleware');当版本为高版本的时候。 高版本 const {createProxyMiddleware: proxy} = require('http-proxy-middleware'); module.exports = function (app) { app.use( proxy('/development', { target: 'http://test/webapi/', //secure: false,//是否验证htpps的安全证书,如果域名是https需要配置此项 changeOrigin: true,//必须设置为true pathRewrite: { "^/development": "", }, }) ); }附上 http-proxy-middleware 链接 https://www.npmjs.com/package/http-proxy-middleware |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |