mirror of
https://github.com/direct-img/direct-img.link.git
synced 2026-10-29 07:24:52 +00:00
Feat: Let search engines crawl free. and raise the burst limit to ~20 req/10s
free.* now serves a robots.txt that allows everything, so free images embedded in pages (e.g. apophenia.news articles) can be indexed and used for previews. The main site and ai.* keep the homepage-only robots.txt. The WAF rate limit rule is now 20 req/10s and skips known bots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,7 +33,12 @@ export async function onRequest(context) {
|
||||
// Every alert ends with the full request URL (site, query, ?i= and ?src=), so it's clear which request triggered it
|
||||
const note = n => context.waitUntil(notify(env, { ...n, message: `${n.message}\n${url.origin}/${path}${url.search}` }));
|
||||
|
||||
// _routes.json serves these statically without invoking this function; kept as a fallback
|
||||
// free.* images are public domain or CC0 and its searches cost no credits, so search engines may crawl them (e.g. to
|
||||
// index images embedded in articles). The main site and ai.* get robots.txt, which allows only the homepage.
|
||||
if (path === "robots.txt" && url.hostname.startsWith("free.")) {
|
||||
return new Response("User-agent: *\nAllow: /\n", { headers: { "Content-Type": "text/plain; charset=utf-8" } });
|
||||
}
|
||||
// _routes.json serves these (except robots.txt) statically without invoking this function; kept as a fallback
|
||||
if (!path || path === "index.html" || path === "robots.txt" || path.startsWith("assets/")) {
|
||||
return env.ASSETS.fetch(request);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user