首页 > 解决方案 > 我在expressjs中使用如下配置,在nestjs中如何使用呢?

问题描述

在nestjs中直接使用会报错

app.get('*', function (request, response){
  response.sendFile(path.resolve(__dirname, 'public', 'index.html'))
})

标签: nestjs

解决方案


我不知道这是否正确,但它已经达到了我的目标。

  app.use((req, res) => {
    if (req.method === 'GET') {
      res.sendFile(
        path.resolve(__dirname, '..', 'public', 'build', 'index.html'),
      );
    }
  });

推荐阅读