Upgrading to 0.7
0.7 rate limits writes to your API by default. Each client may send 120 requests per minute with any method except GET, HEAD, OPTIONS and TRACE. More answer 429 with Retry-After.
Behind a reverse proxy
Clients are told apart by call.request.origin.remoteHost. Without forwarded headers, every request seems to come from the proxy, so all users share one budget. Install Ktor's XForwardedHeaders or ForwardedHeaders before upgrading.
Apps with heavy write traffic
Raise the default, or turn it off for one deployment:
install(Svelte) {
rateLimit {
apiWrites = 600
}
}rateLimit { enabled = false } turns it off completely.
Apps that install Ktor's RateLimit themselves
ktor-svelte now installs Ktor's RateLimit plugin, and Ktor allows it only once. Move your limits into rateLimit { limit(...) } and keep wrapping routes with rateLimit(RateLimitName("...")):
install(Svelte) {
rateLimit {
limit("login", requests = 5, per = 1.minutes)
}
}
routing {
rateLimit(RateLimitName("login")) {
post("/api/login") { /* ... */ }
}
}Or set rateLimit { enabled = false } and keep your own installation.
Tests
Tests that send many writes in a row can now get 429. Raise apiWrites in the test setup, or turn the limit off there. See Rate limit.