网站搜索

reactjs - 使用 tRPC 设置速率限制器


嘿,我尝试在 tRPC 中设置 express-rate-limit,但它不起作用。我怎样才能让它工作?

const test= t.middleware(async ({ next, ctx: { req, res } }) => {
   rateLimit({
      windowMs: 60 * 60 * 1000, // 1 hour
      max: 5,
      message: 'Too many accounts created from this IP, please try again after an hour',
      standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers
      legacyHeaders: false, // Disable the `X-RateLimit-*` headers
   })(req, res, next)
})