nestjs - 我在expressjs中使用如下配置,在nestjs中如何使用呢?
问题描述
在nestjs中直接使用会报错
app.get('*', function (request, response){
response.sendFile(path.resolve(__dirname, 'public', 'index.html'))
})
解决方案
我不知道这是否正确,但它已经达到了我的目标。
app.use((req, res) => {
if (req.method === 'GET') {
res.sendFile(
path.resolve(__dirname, '..', 'public', 'build', 'index.html'),
);
}
});
推荐阅读
- algorithm - 仅通过基本运算符(MTWTFSS)构建掩码以查找特定日期是否匹配
- android - 尝试用 customrom.zip 中的 magisk 替换 supersu
- javascript - 打字稿 - 没有带有“字符串”类型参数的索引签名
- python - 如何将 Python/Pandas 数据插入规范化数据库
- html - 将鼠标悬停在类上时更改 li 类的 CSS
- ruby-on-rails - 对 Presenter 使用索引会导致 NoMethodError
- google-apps-script - 通过 Google Apps 脚本打开 Chrome 选项卡
- android - 在 Kotlin 中实现滑动手势
- r - 如何随机化和循环分类变量列表?
- javascript - 追加除指定变量外的整个数组