How to use a simple Rate Limiter in Cloudflare Workers

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ม.ค. 2025

ความคิดเห็น • 17

  • @andrey.fadeev
    @andrey.fadeev  9 หลายเดือนก่อน +2

    ☕ If you liked this video and want to support my channel, please consider buying me a coffee. Your contribution helps me create more content like this:
    👉 Buy Me a Coffee: www.buymeacoffee.com/andrey.fadeev
    👉 Ko-fi: ko-fi.com/andreyfadeev
    Please also subscribe to my other resources:
    👉 Substack: blog.andreyfadeev.com
    👉 Telegram: t.me/andreyfadeevchannel
    I'm truly grateful for your support, and thank you for watching! 🙏

  • @shlomo.moshe.finkelstein
    @shlomo.moshe.finkelstein 2 หลายเดือนก่อน +2

    Exactly what I needed, thank you!

  • @banafish
    @banafish 9 หลายเดือนก่อน +3

    I'm really enjoying all of your Cloudflare videos.

    • @andrey.fadeev
      @andrey.fadeev  9 หลายเดือนก่อน

      Glad to hear it!

  • @andredealbuquerque105
    @andredealbuquerque105 9 หลายเดือนก่อน +4

    how wre you sending emails with workers? nodemailer didnt seem to work?
    great video!

    • @andrey.fadeev
      @andrey.fadeev  9 หลายเดือนก่อน

      Hi, tbh, I've not done that yet, but I will soon. I was planning to use HTTP API of Mailgun (don't see a reason why that won't work), but I also discovered that you can use MailChannels from Cloudflare workers (so maybe it's even better option).
      Yeah, nodemailer won't work due to nodejs deps, as I understand.

    • @andredealbuquerque105
      @andredealbuquerque105 9 หลายเดือนก่อน +1

      @@andrey.fadeev Ah so youre expecting to potentially send emails via a 3rd party http client. I saw MailChannels, but still havent figured out how to set that tup. Really curious to see how you do it :)

    • @andrey.fadeev
      @andrey.fadeev  9 หลายเดือนก่อน

      @@andredealbuquerque105 I've seen a blog post from Cloudflare: Send email using Workers with MailChannels, there is a code snippet, plus MailChannels requires domain lock down
      Will try that soon and see how it goes :)

  • @sujjee
    @sujjee 4 หลายเดือนก่อน +3

    i tried to build this with hono but its not working after deploy.
    so the issue is when i try to make request form browser it is showing rate limited but when using postman then rate limit not working why so ?

    • @andrey.fadeev
      @andrey.fadeev  4 หลายเดือนก่อน +1

      what are you using as key? maybe log that out and see if its same?

    • @sujjee
      @sujjee 4 หลายเดือนก่อน +1

      ​@@andrey.fadeev​ using ip address. also i tried with without hono. just having same issue it got rate limited in browser but when using postman for request. no rate limit hits.

  • @ffckode
    @ffckode 4 หลายเดือนก่อน +2

    How do you create Integration Tests for Workers that have Rate Limiters?

    • @andrey.fadeev
      @andrey.fadeev  4 หลายเดือนก่อน

      It’s possible to disable rate limiter in test setup or you want to test rate limiting itself?

    • @ffckode
      @ffckode 4 หลายเดือนก่อน

      ​@@andrey.fadeevyes, I would like to test the rate limiter because it is 'activated' in different conditions. Their docs is very poor on that part. Perhaps you can share something about your experience with that. Thanks for the content and for taking the question.

    • @andrey.fadeev
      @andrey.fadeev  4 หลายเดือนก่อน

      @@ffckode there is a tool wrangler that's usually used to create local test environment as well (and it's possible to have test version of D1 db for example), I would expect eventually rate limiter could be configured in test as well, but as it's still in beta I'm not sure it's possible now
      probably the way to go is to use good old stubs/mocks in the test and wrap that rate limiter logic

  • @blackdash225
    @blackdash225 2 หลายเดือนก่อน +1

    do these requests that get rejected with rate limiting still count towards your worker invocations?

    • @andrey.fadeev
      @andrey.fadeev  2 หลายเดือนก่อน

      I think so yeah, it was beta at that point, maybe it will change