0
Get Browser Check setting
One script reply has been approved by the moderators Verified

Browser Integrity Check is similar to Bad Behavior and looks for common HTTP headers abused most commonly by spammers and denies access to your page. It will also challenge visitors that do not have a user agent or a non standard user agent (also commonly used by abuse bots, crawlers or visitors). (https://support.cloudflare.com/hc/en-us/articles/200170086).

Created by hugo697 254 days ago Viewed 8904 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 254 days ago
1
type Cloudflare = {
2
  token: string;
3
  email: string;
4
  key: string;
5
};
6
/**
7
 * Get Browser Check setting
8
 * Browser Integrity Check is similar to Bad Behavior and looks for common HTTP headers abused most commonly by spammers and denies access to your page.  It will also challenge visitors that do not have a user agent or a non standard user agent (also commonly used by abuse bots, crawlers or visitors). (https://support.cloudflare.com/hc/en-us/articles/200170086).
9
 */
10
export async function main(auth: Cloudflare, zone_identifier: string) {
11
  const url = new URL(
12
    `https://api.cloudflare.com/client/v4/zones/${zone_identifier}/settings/browser_check`
13
  );
14

15
  const response = await fetch(url, {
16
    method: "GET",
17
    headers: {
18
      "X-AUTH-EMAIL": auth.email,
19
      "X-AUTH-KEY": auth.key,
20
      Authorization: "Bearer " + auth.token,
21
    },
22
    body: undefined,
23
  });
24
  if (!response.ok) {
25
    const text = await response.text();
26
    throw new Error(`${response.status} ${text}`);
27
  }
28
  return await response.json();
29
}
30