Files
kolaytercih/src/proxy.ts
bilalgursen 47d0685433
All checks were successful
Deploy / deploy (push) Successful in 13m23s
fix(olcum): Tencent/Huawei bulut botları sunucuda 403 ile kesiliyor, Rybbit betiği otomasyon tarayıcısında yüklenmiyor
Ekim'de Rybbit oturumlarının üçte ikisi Singapur/Çin veri merkezlerinden gelen
headless Chrome'du. src/proxy.ts, x-forwarded-for'un son öğesini
src/lib/engellenen-araliklar.ts'teki RDAP ile doğrulanmış CIDR listesiyle
karşılaştırıp sayfa render edilmeden 403 döner. Rybbit betiği
navigator.webdriver açıkken yüklenmez; giriş linki nofollow. Ayrıntı ve
kanıt docs/ekip-raporlari/2026-10-16/. Sürüm artmadı: kullanıcıya görünmez.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-16 00:26:31 +03:00

28 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { NextResponse, type NextRequest } from "next/server";
import { ipEngelliMi, istemciIp } from "@/lib/engellenen-araliklar";
/**
* Her isteğin önünde çalışır (Next "proxy" dosya konvansiyonu; eski adı
* middleware). Tek işi var: bulut sunucularından gelen bot taramasını
* (Tencent/Huawei aralıkları, bkz. `src/lib/engellenen-araliklar.ts`) sayfa
* render edilmeden 403 ile kesmek. Böylece bot ne Rybbit'e oturum yazar ne
* de SQLite'ı ve V8 heap'ini boşa yorar.
*
* Kapsam dışı: `_next/static` ve `_next/image` (sayfa 403 alınca tarayıcı
* bunları zaten istemez; gerçek kullanıcının varlık isteklerine ek maliyet
* binmesin) ve `/api/saglik` (konteyner içi sağlık kontrolü, XFF başlığı yok).
*/
export function proxy(request: NextRequest) {
if (ipEngelliMi(istemciIp(request.headers))) {
return new NextResponse("Erişim engellendi.", {
status: 403,
headers: { "content-type": "text/plain; charset=utf-8" },
});
}
return NextResponse.next();
}
export const config = {
matcher: ["/((?!_next/static|_next/image|api/saglik).*)"],
};