diff --git a/src/content/docs/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-522.mdx b/src/content/docs/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-522.mdx
index a484eee86056215..17e7e5a8917248d 100644
--- a/src/content/docs/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-522.mdx
+++ b/src/content/docs/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-522.mdx
@@ -27,9 +27,9 @@ Two different timeouts cause HTTP error `522` depending on when they occur betwe
- If you are using [Cloudflare Pages](/pages/), verify that you have a custom domain set up and that your CNAME record is pointed to your [custom Pages domain](/pages/configuration/custom-domains/#add-a-custom-domain).
-- If you are using [Workers with a Custom Domain](/workers/configuration/routing/custom-domains/), performing a `fetch` to its own hostname will cause a `522` error. Consider using a [Route](/workers/configuration/routing/) or target another hostname instead.
+- If you are using [Workers with a Custom Domain](/workers/configuration/routing/custom-domains/), performing a `fetch` to its own hostname will cause a `522` error. Consider using a [Route](/workers/configuration/routing/), targeting another hostname, or enabling the [`global_fetch_strictly_public` compatibility flag](/workers/configuration/compatibility-flags/#global-fetch-strictly-public) instead.
- If none of the above leads to a resolution, request the following information from your hosting provider or site administrator before [contacting Cloudflare support](/support/contacting-cloudflare-support/):
- An [MTR or traceroute](/support/troubleshooting/general-troubleshooting/gathering-information-for-troubleshooting-sites/#perform-a-traceroute) from your origin web server to a [Cloudflare IP address](http://www.cloudflare.com/ips) that most commonly connected to your origin web server before the issue occurred. Identify a connecting Cloudflare IP recorded in the origin web server logs.
- - Details from the hosting provider's investigation, such as pertinent logs or conversations with the hosting provider.
\ No newline at end of file
+ - Details from the hosting provider's investigation, such as pertinent logs or conversations with the hosting provider.
diff --git a/src/content/docs/workers/observability/errors.mdx b/src/content/docs/workers/observability/errors.mdx
index a1f011dd641b10b..bb0b5564e5e2dfb 100644
--- a/src/content/docs/workers/observability/errors.mdx
+++ b/src/content/docs/workers/observability/errors.mdx
@@ -13,18 +13,18 @@ Review Workers errors and exceptions.
When a Worker running in production has an error that prevents it from returning a response, the client will receive an error page with an error code, defined as follows:
-| Error code | Meaning |
-| ---------- | ----------------------------------------------------------------------------------------------------------------- |
-| `1101` | Worker threw a JavaScript exception. |
-| `1102` | Worker exceeded [CPU time limit](/workers/platform/limits/#cpu-time). |
-| `1103` | The owner of this worker needs to contact [Cloudflare Support](/support/contacting-cloudflare-support/) |
-| `1015` | Worker hit the [burst rate limit](/workers/platform/limits/#burst-rate). |
-| `1019` | Worker hit [loop limit](#loop-limit). |
-| `1021` | Worker has requested a host it cannot access. |
-| `1022` | Cloudflare has failed to route the request to the Worker. |
-| `1024` | Worker cannot make a subrequest to a Cloudflare-owned IP address. |
-| `1027` | Worker exceeded free tier [daily request limit](/workers/platform/limits/#daily-request). |
-| `1042` | Worker tried to fetch from another Worker on the same zone, which is [unsupported](/workers/runtime-apis/fetch/). |
+| Error code | Meaning |
+| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
+| `1101` | Worker threw a JavaScript exception. |
+| `1102` | Worker exceeded [CPU time limit](/workers/platform/limits/#cpu-time). |
+| `1103` | The owner of this worker needs to contact [Cloudflare Support](/support/contacting-cloudflare-support/) |
+| `1015` | Worker hit the [burst rate limit](/workers/platform/limits/#burst-rate). |
+| `1019` | Worker hit [loop limit](#loop-limit). |
+| `1021` | Worker has requested a host it cannot access. |
+| `1022` | Cloudflare has failed to route the request to the Worker. |
+| `1024` | Worker cannot make a subrequest to a Cloudflare-owned IP address. |
+| `1027` | Worker exceeded free tier [daily request limit](/workers/platform/limits/#daily-request). |
+| `1042` | Worker tried to fetch from another Worker on the same zone, which is only [supported](/workers/runtime-apis/fetch/) when the [`global_fetch_strictly_public` compatibility flag](/workers/configuration/compatibility-flags/#global-fetch-strictly-public) is used. |
Other `11xx` errors generally indicate a problem with the Workers runtime itself. Refer to the [status page](https://www.cloudflarestatus.com) if you are experiencing an error.
@@ -255,10 +255,10 @@ The **Errors by invocation status** chart shows the number of errors broken down
The **Client disconnected by type** chart shows the number of client disconnect errors broken down into the following categories:
-| Client Disconnects | Meaning |
-| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Client Disconnects | Meaning |
+| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Response Stream Disconnected` | Connection was terminated during the deferred proxying stage of a Worker request flow. It commonly appears for longer lived connections such as [WebSockets](/workers/runtime-apis/websockets/). |
-| `Cancelled` | The Client disconnected before the Worker completed its response. |
+| `Cancelled` | The Client disconnected before the Worker completed its response. |
## Debug exceptions with Workers Logs
diff --git a/src/content/docs/workers/runtime-apis/fetch.mdx b/src/content/docs/workers/runtime-apis/fetch.mdx
index 539b374aa3de286..27b290184c4d37d 100644
--- a/src/content/docs/workers/runtime-apis/fetch.mdx
+++ b/src/content/docs/workers/runtime-apis/fetch.mdx
@@ -4,26 +4,21 @@ title: Fetch
head: []
description: An interface for asynchronously fetching resources via HTTP
requests inside of a Worker.
-
---
-import { TabItem, Tabs } from "~/components"
+import { TabItem, Tabs } from "~/components";
The [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) provides an interface for asynchronously fetching resources via HTTP requests inside of a Worker.
:::note
-
Asynchronous tasks such as `fetch` must be executed within a [handler](/workers/runtime-apis/handlers/). If you try to call `fetch()` within [global scope](https://developer.mozilla.org/en-US/docs/Glossary/Global_scope), your Worker will throw an error. Learn more about [the Request context](/workers/runtime-apis/request/#the-request-context).
-
:::
:::caution[Worker to Worker]
-
-Worker-to-Worker `fetch` requests are possible with [Service bindings](/workers/runtime-apis/bindings/service-bindings/).
-
+Worker-to-Worker `fetch` requests are possible with [Service bindings](/workers/runtime-apis/bindings/service-bindings/) or by enabling the [`global_fetch_strictly_public` compatibility flag](/workers/configuration/compatibility-flags/#global-fetch-strictly-public).
:::
@@ -33,28 +28,28 @@ Worker-to-Worker `fetch` requests are possible with [Service bindings](/workers/
```js null {3-7}
export default {
- async scheduled(controller, env, ctx) {
- return await fetch("https://example.com", {
- headers: {
- "X-Source": "Cloudflare-Workers",
- },
- });
- },
+ async scheduled(controller, env, ctx) {
+ return await fetch("https://example.com", {
+ headers: {
+ "X-Source": "Cloudflare-Workers",
+ },
+ });
+ },
};
```
```js null {8}
-addEventListener('fetch', event => {
- // NOTE: can’t use fetch here, as we’re not in an async scope yet
- event.respondWith(eventHandler(event));
+addEventListener("fetch", (event) => {
+ // NOTE: can’t use fetch here, as we’re not in an async scope yet
+ event.respondWith(eventHandler(event));
});
async function eventHandler(event) {
- // fetch can be awaited here since `event.respondWith()` waits for the Promise it receives to settle
- const resp = await fetch(event.request);
- return resp;
+ // fetch can be awaited here since `event.respondWith()` waits for the Promise it receives to settle
+ const resp = await fetch(event.request);
+ return resp;
}
```
@@ -70,29 +65,23 @@ async def on_scheduled(controller, env, ctx):
+- fetch(resource, options optional) : Promise``
-
-* fetch(resource, options optional) : Promise``
-
- * Fetch returns a promise to a Response.
-
-
+ - Fetch returns a promise to a Response.
### Parameters
+- [`resource`](https://developer.mozilla.org/en-US/docs/Web/API/fetch#resource) Request | string | URL
+- `options` options
+ - `cache` `undefined | 'no-store'` optional
+ - Standard HTTP `cache` header. Only `cache: 'no-store'` is supported.
+ Any other `cache` header will result in a `TypeError` with the message `Unsupported cache mode: `.
+ _ For all requests this forwards the `Pragma: no-cache` and `Cache-Control: no-cache` headers to the origin.
+ _ For requests to origins not hosted by Cloudflare, `no-store` bypasses the use of Cloudflare's caches.
+ - An object that defines the content and behavior of the request.
-* [`resource`](https://developer.mozilla.org/en-US/docs/Web/API/fetch#resource) Request | string | URL
-
-* `options` options
- * `cache` `undefined | 'no-store'` optional
- * Standard HTTP `cache` header. Only `cache: 'no-store'` is supported.
- Any other `cache` header will result in a `TypeError` with the message `Unsupported cache mode: `.
- * For all requests this forwards the `Pragma: no-cache` and `Cache-Control: no-cache` headers to the origin.
- * For requests to origins not hosted by Cloudflare, `no-store` bypasses the use of Cloudflare's caches.
- * An object that defines the content and behavior of the request.
-
-***
+---
## How the `Accept-Encoding` header is handled
@@ -110,28 +99,31 @@ In addition to a change in the content encoding, recompression is also needed wh
```typescript
export default {
- async fetch(request) {
- // Accept brotli or gzip compression
- const headers = new Headers({
- 'Accept-Encoding': "br, gzip"
- });
- let response = await fetch("https://developers.cloudflare.com", {method: "GET", headers});
-
- // As long as the original response body is returned and the Content-Encoding header is
- // preserved, the same encoded data will be returned without needing to be compressed again.
- return new Response(response.body, {
- status: response.status,
- statusText: response.statusText,
- headers: response.headers,
- });
- }
-}
+ async fetch(request) {
+ // Accept brotli or gzip compression
+ const headers = new Headers({
+ "Accept-Encoding": "br, gzip",
+ });
+ let response = await fetch("https://developers.cloudflare.com", {
+ method: "GET",
+ headers,
+ });
+
+ // As long as the original response body is returned and the Content-Encoding header is
+ // preserved, the same encoded data will be returned without needing to be compressed again.
+ return new Response(response.body, {
+ status: response.status,
+ statusText: response.statusText,
+ headers: response.headers,
+ });
+ },
+};
```
## Related resources
-* [Example: use `fetch` to respond with another site](/workers/examples/respond-with-another-site/)
-* [Example: Fetch HTML](/workers/examples/fetch-html/)
-* [Example: Fetch JSON](/workers/examples/fetch-json/)
-* [Example: cache using Fetch](/workers/examples/cache-using-fetch/)
-* Write your Worker code in [ES modules syntax](/workers/reference/migrate-to-module-workers/) for an optimized experience.
\ No newline at end of file
+- [Example: use `fetch` to respond with another site](/workers/examples/respond-with-another-site/)
+- [Example: Fetch HTML](/workers/examples/fetch-html/)
+- [Example: Fetch JSON](/workers/examples/fetch-json/)
+- [Example: cache using Fetch](/workers/examples/cache-using-fetch/)
+- Write your Worker code in [ES modules syntax](/workers/reference/migrate-to-module-workers/) for an optimized experience.