我有以下前端中间件:
export class FrontendMiddleware implements NestMiddleware {
use(req: any, res: any, next: () => void) {
const url = req.originalUrl;
if (url.indexOf('rest') === 1) {
next();
} else if (allowedExt.filter(ext => url.indexOf(ext) > 0).length > 0) {
res.sendFile(resolvePath(url));
} else {
res.sendFile(resolvePath('index.html'));
}
}
}
它适用于 express,但适用于 fastify, res.sendFile
is undefined
,那么我该如何解决呢?