<BrowserRouter>
<Route path="/" exact component={Home}/>
<Route path="/list" component={List}/>
</BrowserRouter>
localhost:8080/能正确找到
localhost:8080/list找不到
devServer: {
// historyApiFallback: {
// rewrites: [
// { from: /\.*/, to: '/index.html' }
// ]
// },
historyApiFallback:true,//加这个可以解决找不到文件的问题
contentBase: './dist',
open: true,
port: 8080,
hot: true,
hotOnly: true,
proxy:{
'/react/api':{
target:'http://www.dell-lee.com',
changeOrigin: true,//解决后台对跨域的限制
secure: false,//https时需配置
// pathRewrite:{'header.json':'demo.json'}// 将header.json接口未写好时暂时转发到写好demo.json上去测试,上线后则注销此转发
headers:{
host:'www.dell-lee.com',
cookie:'sfsd'
}
}
}
},