JS后端 按视频操作 浏览器无连接

  //计算服务器消耗时长的中间件
    module.exports=async(ctx,next)=>{
    //记录开始时间
    const  start=Date.now()
    //让内层中间件得到执行
     await next()
    //记录结束的时间
    const  end=Date.now()
    //设置响应头 X-Response_Time
    const duration=end-start
    //ctx.set 设置响应头
    ctx.set('X-Response_Time',duration+'ms')


}

 

服务器运行起来了吗,运行起来了你可以看看Network的XHR里面的东西说不定会有帮助