sendfile returns a promise that resolves to thefs.stat()result of the filename. If sendfile() resolves, that doesn't mean that a response is set - the filename could be a directory. Instead, checkif (context.status). constsendfile=require('koa-sendfile') ...
res.sendFile(__dirname+'/index.html'); }); http.listen(5566,function(){console.log('listening on *:5566'); }); 变成koa2 应该怎么写? 网上的教程都是只有这样: constKoa=require('koa');constapp =newKoa(); app.use(async(ctx, next) => {awaitnext(); ctx.response.type='text/html';...