今天遇到了一个问题就是项目中的get请求成功了,response返回的是index.html,后来发现是这里的问题,不明白为啥这样写
问题描述
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
app.get('*', (req, res) => {
fs.readFile(path.join(compiler.outputPath, 'index.html'), (err, file) => {
if (err) {
res.sendStatus(404);
} else {
res.send(file.toString());
}
});
});
应该是单页面网页的写法吧,当路由模式是history的时候