Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/103-early-hints.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ sidebar:
description: Allow a client to request static assets while waiting for the HTML response.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/103-early-hints)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

`103` Early Hints is an HTTP status code designed to speed up content delivery. When enabled, Cloudflare can cache the `Link` headers marked with preload and/or preconnect from HTML pages and serve them in a `103` Early Hints response before reaching the origin server. Browsers can use these hints to fetch linked assets while waiting for the origin’s final response, dramatically improving page load speeds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ description: Access custom Cloudflare properties and control how Cloudflare
features are applied to every request.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/accessing-the-cloudflare-object)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/aggregate-requests.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ description: Send two GET request to two urls and aggregates the responses into
one response.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/aggregate-requests)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/alter-headers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ description: Example of how to add, change, or delete headers sent in a request
or returned in a response.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/alter-headers)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/cache-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ sidebar:
description: Use the Cache API to store responses in Cloudflare's cache.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/cache-api)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/cache-post-request.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ sidebar:
description: Cache POST requests using the Cache API.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/cache-post-request)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/cache-tags.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ sidebar:
description: Send Additional Cache Tags using Workers
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/cache-tags)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/cache-using-fetch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ description: Determine how to cache a resource by setting TTLs, custom cache
keys, and cache headers in a fetch request.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/cache-using-fetch)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/conditional-response.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ description: Return a response based on the incoming request's URL, HTTP method,
User Agent, IP address, ASN or device type.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/conditional-response)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/cors-header-proxy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ sidebar:
description: Add the necessary CORS headers to a third party API response.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/cors-header-proxy)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/country-code-redirect.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ sidebar:
description: Redirect a response based on the country code in the header of a visitor.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/country-code-redirect)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/cron-trigger.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ sidebar:
description: Set a Cron Trigger for your Worker.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/cron-trigger)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { Render, TabItem, Tabs, WranglerConfig } from "~/components";

<Render file="cron-trigger-example" />
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/data-loss-prevention.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ description: Protect sensitive data to prevent data loss, and send alerts to a
webhooks server in the event of a data breach.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/data-loss-prevention)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/debugging-logs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ sidebar:
description: Send debugging information in an errored response to a logging service.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/debugging-logs)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/extract-cookie-value.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ description: Given the cookie name, get the value of a cookie. You can also use
cookies for A/B testing.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/extract-cookie-value)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/fetch-html.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ description: Send a request to a remote server, read HTML from the response, and
serve that HTML.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/fetch-html)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { Render, TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/fetch-json.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ description: Send a GET request and read in JSON from the response. Use to fetch
external data.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/fetch-json)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ sidebar:
description: Fetch weather data from an API using the user's geolocation data.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/geolocation-app-weather)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ sidebar:
description: Personalize website styling based on localized user time.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/geolocation-custom-styling)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ sidebar:
description: Get all geolocation data fields and display them in HTML.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/geolocation-hello-world)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/hot-link-protection.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ description: Block other websites from linking to your content. This is useful
for protecting images.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/hot-link-protection)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/images-workers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ description: Set up custom domain for Images using a Worker or serve images
using a prefix path and Cloudflare registered domain.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/images-workers)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

To serve images from a custom domain:
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/logging-headers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ sidebar:
description: Examine the contents of a Headers object by logging to console with a Map.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/logging-headers)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ description: Create a modified request with edited properties based off of an
incoming request.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/modify-request-property)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/modify-response.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ description: Fetch and modify response properties which are immutable by
creating a copy first.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/modify-response)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ sidebar:
description: Set multiple Cron Triggers on three different schedules.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/multiple-cron-triggers)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/openai-sdk-streaming.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ head: []
description: Use the OpenAI v4 SDK to stream responses from OpenAI.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/openai-sdk-streaming)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

In order to run this code, you must install the OpenAI SDK by running `npm i openai`.
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/post-json.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ sidebar:
description: Send a POST request with JSON data. Use to share data with external servers.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/post-json)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ description: Protect against timing attacks by safely comparing values using
`timingSafeEqual`.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/protect-against-timing-attacks)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

The [`crypto.subtle.timingSafeEqual`](/workers/runtime-apis/web-crypto/#timingsafeequal) function compares two values using a constant-time algorithm. The time taken is independent of the contents of the values.
Expand Down
6 changes: 6 additions & 0 deletions src/content/docs/workers/examples/read-post.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ description: Serve an HTML form, then read POST requests. Use also to read JSON
or POST data from an incoming request.
---

If you want to get started quickly, click on the button below.

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/docs-examples/tree/main/workers/read-post)

This creates a repository in your GitHub account and deploys the application to Cloudflare Workers.

import { TabItem, Tabs } from "~/components";

<Tabs syncKey="workersExamples"> <TabItem label="JavaScript" icon="seti:javascript">
Expand Down
Loading