How to configure ratelimit on environment level?

Heya! I am trying to follow the documentation and setting up a rate limiter our worker. It seems that [[unsafe.binding]] does not work in top-level when [env] is being used:
- "env.development" environment configuration
- "unsafe" exists at the top level, but not on "env.development".
This is not what you probably want, since "unsafe" is not inherited by environments.
Please add "unsafe" to "env.development".
- "env.development" environment configuration
- "unsafe" exists at the top level, but not on "env.development".
This is not what you probably want, since "unsafe" is not inherited by environments.
Please add "unsafe" to "env.development".
How should I configure rate limiter whilst using environments? 🤔
1 Reply
snapo
snapo•4mo ago
This syntax seems to get rid of the error:
[env]
[env.development.unsafe]
bindings = [
{ name = "MY_RATE_LIMIT", type = "ratelimit", namespace_id = "1001", simple = { limit = 60, period = 60 } }
]
[env]
[env.development.unsafe]
bindings = [
{ name = "MY_RATE_LIMIT", type = "ratelimit", namespace_id = "1001", simple = { limit = 60, period = 60 } }
]
Investigating if it actually works! Thanks @Leo ! Can [env.development.unsafe] and [env.development] co-exists like this?
[env]
[env.development.unsafe]
bindings = [
{ name = "rateLimit10RequestsPerMinute", type = "ratelimit", namespace_id = "1001", simple = { limit = 10, period = 60 } },
]
[env.development]
...other stable configurations
[env]
[env.development.unsafe]
bindings = [
{ name = "rateLimit10RequestsPerMinute", type = "ratelimit", namespace_id = "1001", simple = { limit = 10, period = 60 } },
]
[env.development]
...other stable configurations
This sems to work, but not sure if a good practice. What I am after is separating unsafe things from stable things
Want results from more Discord servers?
Add your server