GithubHelp home page GithubHelp logo

Comments (3)

rayriffy avatar rayriffy commented on August 15, 2024

This is not a bug. By default rateLimit context will be applied globally and disregarding any hierarchy, use scoping option to make plugin affect per routes.

from elysia-rate-limit.

doroved avatar doroved commented on August 15, 2024

This is not a bug. By default rateLimit context will be applied globally and disregarding any hierarchy, use scoping option to make plugin affect per routes.

scope has nothing to do with it. You need to add url.pathname to the key in the generator
Maybe it's better to make it by default, so you don't have to specify it every time.
Otherwise now, if you exhaust the limit on one router you will be blocked everywhere!

That's how it should be.

    generator: (req) => {
      const path = new URL(req.url).pathname
      const ip = req.headers.get('x-real-ip')

      const res = ip !== null ? ip : 'anonymous'
      return res + path
    },

You were clearly in a hurry to close the issue.

from elysia-rate-limit.

rayriffy avatar rayriffy commented on August 15, 2024

scoping is meant to separate rate limit per instances to grouping by each categories, by design rate limit should be counted globally this is also a default behavior for fastify, and express as well. If you want per api route you should create your own generator that's what it's designed for. this project should not cover every tiny cases otherwise it will be extremely bloated

and do not make an accusation like that to anyone EVER

from elysia-rate-limit.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.