Skip to content

Commit f93f5f4

Browse files
committed
fix: use separate generous rate limiter for /info endpoint
The /info endpoint shared the session rate limiter (30s/req, burst 3) which was far too aggressive for a public read-only page. Vercel server-side rendering + metadata generation would hit the limit on normal page loads, returning 429 and causing 503 errors. New public_read_limit: 2s/req, burst 15 -- appropriate for a read-only endpoint that serves donation campaign pages.
1 parent 04d29ce commit f93f5f4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/api/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ pub fn configure(cfg: &mut web::ServiceConfig) {
3535
.finish()
3636
.expect("Failed to build session rate limiter");
3737

38+
let public_read_limit = GovernorConfigBuilder::default()
39+
.seconds_per_request(2)
40+
.burst_size(15)
41+
.finish()
42+
.expect("Failed to build public read rate limiter");
43+
3844
cfg.service(
3945
web::scope("/api")
4046
.route("/health", web::get().to(health))
@@ -91,7 +97,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) {
9197
.route("/payment-links/{id}", web::patch().to(payment_links::update))
9298
.route("/payment-links/{id}", web::delete().to(payment_links::delete))
9399
.route("/payment-links/{slug}/checkout", web::post().to(payment_links::resolve).wrap(Governor::new(&session_rate_limit)))
94-
.route("/payment-links/{slug}/info", web::get().to(payment_links::info).wrap(Governor::new(&session_rate_limit)))
100+
.route("/payment-links/{slug}/info", web::get().to(payment_links::info).wrap(Governor::new(&public_read_limit)))
95101
// Donation links (merchant auth)
96102
.route("/donation-links", web::post().to(payment_links::create_donation))
97103
// Buyer checkout (public)

0 commit comments

Comments
 (0)