type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Change Browser Check setting
* 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).
*/
export async function main(
auth: Cloudflare,
zone_identifier: string,
body: { value: "on" | "off"; [k: string]: unknown }
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/settings/browser_check`
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 403 days ago
type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Change Browser Check setting
* 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).
*/
export async function main(
auth: Cloudflare,
zone_identifier: string,
body: { value: "on" | "off"; [k: string]: unknown }
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/settings/browser_check`
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 941 days ago