Get Origin Max HTTP Version setting

The highest HTTP version Cloudflare will attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 requests to your origin. (Refer to [Enable HTTP/2 to Origin](https://developers.cloudflare.com/cache/how-to/enable-http2-to-origin/), for more information.).

Script cloudflare Verified

by hugo697 ยท 11/16/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 383 days ago
1
type Cloudflare = {
2
  token: string;
3
  email: string;
4
  key: string;
5
};
6
/**
7
 * Get Origin Max HTTP Version setting
8
 * The highest HTTP version Cloudflare will attempt to use with your
9
origin. This setting allows Cloudflare to make HTTP/2 requests to your
10
origin. (Refer to 
11
[Enable HTTP/2 to Origin](https://developers.cloudflare.com/cache/how-to/enable-http2-to-origin/),
12
for more information.).
13

14
 */
15
export async function main(auth: Cloudflare, zone_identifier: string) {
16
  const url = new URL(
17
    `https://api.cloudflare.com/client/v4/zones/${zone_identifier}/settings/origin_max_http_version`
18
  );
19

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