Match Facebook user agents as bots

This commit is contained in:
dangered wolf 2022-07-15 01:11:32 -04:00
parent a4d5dda635
commit d7fd20c933
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58

View file

@ -10,7 +10,7 @@ const statusRequest = async (request: any, event: FetchEvent) => {
const url = new URL(request.url); const url = new URL(request.url);
const userAgent = request.headers.get('User-Agent'); const userAgent = request.headers.get('User-Agent');
if (userAgent.match(/bot/gi) !== null) { if (userAgent.match(/bot|facebook/gi) !== null) {
// https://developers.cloudflare.com/workers/examples/cache-api/ // https://developers.cloudflare.com/workers/examples/cache-api/
const cacheUrl = new URL(request.url); const cacheUrl = new URL(request.url);
const cacheKey = new Request(cacheUrl.toString(), request); const cacheKey = new Request(cacheUrl.toString(), request);