Blog
SavedSearch
Visit Hostlelo

Cloudflare Gateway Workers Beta: Verify the Request Path First

Cloudflare’s new Gateway–Workers beta adds code to permitted HTTP traffic. Start with a scoped pilot, a response marker and separate inspection checks.

The short answer

Cloudflare launched Gateway–Workers Forward integration in public beta on 15 October 2026. Start with one controlled destination and test device, deploy the named GatewayMiddleware entrypoint, and compare a response marker with policy, Worker and origin evidence. Invocation alone does not prove body inspection or business-task completion. Keep a documented rollback and check Workers usage limits.

A secure purple gateway, a coral processing chip and a server connected by request cards.
Reading options

On this page

Before you start

Authorised Cloudflare/Gateway administration, a managed test device already routed through Gateway HTTP filtering, approved TLS-decryption configuration for HTTPS, a harmless endpoint you control and a recoverable policy/Worker configuration.

Cloudflare's 15 October 2026 update gives administrators a new place to run code: inside the path of HTTP traffic permitted by Gateway. That is useful for a team supporting business applications, but it also creates another component to diagnose when a request behaves unexpectedly.

The first pilot should answer a small question: did the intended request take the intended route? Start there before adding identity decisions, response rewriting or external integrations. The test plan below is an author-proposed rollout approach, not a report of a deployed Hostlelo experiment.

What actually launched on 15 October

The official changelog announces the Gateway–Workers Forward integration in public beta on all Zero Trust plans. The event date and announcement date are both 15 October 2026; this guide was researched on 16 October.

A matching Forward policy can invoke your Worker for permitted traffic. Your code can adjust the request or response, produce a response itself, or perform background work. This is relevant to administrators controlling how managed devices reach business applications. Putting a public website behind Cloudflare DNS alone does not route all its visitors through your organisation's Gateway policies.

Cloudflare's accompanying launch article also discusses separate Gateway Custom Functions planned for later in 2026. Do not read that roadmap as evidence that every announced capability is already available. This guide covers the Forward beta.

Decide whether you need custom code

Write down one behaviour that the existing policy controls cannot express conveniently. For example, a team might need an application-specific response transformation for a controlled internal service. That is a proposed use case, not a recommendation to intercept every employee request.

If built-in filtering already implements the requirement, adding code creates another deployment and recovery responsibility. Teams running AI tools should also inventory what those tools can access; our guide to giving agents website access explains that separate permission problem.

Cloudflare documents the integration as middleware for Gateway traffic. It does not turn a shared-hosting account into a secure web gateway or replace a website's authentication.

Prepare one controlled pilot

Use an account administrator and a test device whose traffic already passes through Gateway HTTP filtering. For HTTPS, the setup requires TLS decryption and a trusted root certificate on that device. Follow your organisation's authorised certificate-deployment procedure; never respond to a failed certificate check by disabling TLS verification.

Choose a test hostname and harmless endpoint you control. Scope the policy to that destination and a test user or device group. Exclude production payments, real customer data and unrelated browsing from the pilot.

Record the existing policy configuration, deployed Worker version, expected endpoint response and rollback owner. First request the endpoint without the experimental Forward policy and save the status and headers. This baseline makes a later marker meaningful.

The setup documentation requires the Worker and Gateway policy to be in the same account. The Worker need not have a public route. Its example configuration disables both workers_dev and preview_urls. Check for any separately configured routes rather than assuming those two settings remove all possible exposure.

Add an observation before adding a decision

Gateway calls a named GatewayMiddleware class through its handle(request, context, next) method. A default Worker fetch() handler is not the integration entrypoint.

This small JavaScript template forwards once and marks the returned response. It is unexecuted and intentionally contains no identity checks, content capture or external notifications:

import { WorkerEntrypoint } from "cloudflare:workers";

export class GatewayMiddleware extends WorkerEntrypoint {
  async handle(request, context, next) {
    const upstream = await next(request);
    const markedHeaders = new Headers(upstream.headers);
    markedHeaders.set("x-hostlelo-gateway-probe", "pilot-20261016");

    return new Response(upstream.body, {
      status: upstream.status,
      statusText: upstream.statusText,
      headers: markedHeaders,
    });
  }
}

If using TypeScript, the context reference specifies @cloudflare/zt-types version 2026.10.1 or later. JavaScript omits those type-only imports and does not need that package.

Deploy through your normal change process, then select the deployed Worker in the narrowly scoped Forward policy. Preserve the exact exported class name.

From the test device, make a GET and inspect the response headers:

curl --silent --show-error \
  --connect-timeout 10 --max-time 20 \
  --dump-header - --output /dev/null \
  https://pilot.example.com/health

Replace the example hostname with your own controlled endpoint. Do not include credentials in a copied command or disable certificate validation. A terminal request may follow different routing from a browser request; verify how the actual test client reaches Gateway.

The marker is a diagnostic clue, not an authentication credential. Another component could add the same header. Compare the baseline, the matching policy and Worker version, and the controlled origin's request evidence.

Separate invocation from inspection and completion

Cloudflare's enforcement documentation distinguishes HTTP request filtering, the Forward phase and body inspection. A request-policy Block prevents invocation. Body inspection can interrupt an already-running Worker, and the final response is inspected.

That means an invocation log alone does not prove that a request body passed inspection or that a business operation finished. The diagram separates those events rather than presenting a single green “success” signal.

Worker invocation, Gateway inspection and application completion are different evidence. Body inspection can interrupt an already-running Worker.

Use this proposed test sheet and record actual results rather than treating the expectations as measurements:

Controlled case

Expected signal

What it does not prove

Baseline without the pilot policy

Original endpoint response; no pilot-added marker

Every possible route is covered

Matching permitted request

Marker, relevant execution evidence and expected endpoint response

Complete policy correctness or application success

Non-matching request through Gateway

Pilot Worker is not selected for that request

Traffic outside the tested scope is protected

Test HTTP request-policy Block

Blocked request; pilot Worker not invoked

Body-policy blocking behaves identically

Remove the experimental Forward policy

Endpoint returns to its recorded baseline

A separate security restriction should be removed

For a body-inspection test, use an approved synthetic fixture and the existing inspection policy. Do not send real secrets as a test. Record the final Gateway action, any Worker evidence and the controlled application's outcome separately. A failed experiment on one device is not evidence of a global Cloudflare outage.

Respect the continuation and metadata boundaries

Use next(request) to continue the original request through Gateway. Cloudflare documents a maximum of one call per invocation; it is not a mechanism for retries, destination changes or fan-out. A normal Workers fetch() creates an independent subrequest and must not be assumed to inherit the user's Gateway routing or egress.

The metadata also has boundaries. Context describes the original request and does not update when your script changes it. Optional values can be absent. If future custom logic needs identity or posture, handle both missing results and retrieval errors explicitly; the context contract distinguishes them.

Do not turn a client-supplied identity header into proof of an authenticated user. Keep the first pilot free of that decision, then review the required behaviour before expanding it.

Costs, protocol checks and a reversible rollout

Availability on every Zero Trust plan is not a promise of unlimited free execution. Cloudflare says dispatched traffic is billed as standard Worker requests. Workers Free has execution and daily-request limits; consult the current Workers pricing and limits for the account you use.

Estimate how many requests the policy can match, what your code does per request and whether it adds storage, logging or other services. A broad selector can include ordinary application resources, not just a user's main page view. No bill estimate or latency benchmark is established by this guide.

Check the documented protocol restrictions before rollout. In particular, the integration overview says WebSocket traffic connects to the original upstream and bypasses the Worker. Do not assume that a successful HTTP probe covers a live WebSocket application.

For recovery, remove or disable the experimental Forward policy through the authorised change process, keep the original security policies in place and repeat the baseline checks. Retain a known Worker version for a controlled retry. If you are also changing hosting, separate those changes using a website migration plan, so the cause of a regression remains identifiable.

Expand only after someone can explain which policy matched, which code ran, what inspection decided and what the application actually received. Those are four useful pieces of evidence, not one interchangeable success badge.

Reader questions

Is the Gateway–Workers integration generally available?

No. Cloudflare announced the Forward integration in public beta on 15 October 2026. Treat beta availability separately from future Gateway Custom Functions described in the launch article.

Does putting my website on Cloudflare enable this for every visitor?

No. Forward acts on traffic passing through the organisation's Gateway configuration and matching its policy. A site's Cloudflare DNS or CDN setup alone does not put all visitors into that path.

Does a Worker invocation prove a request passed DLP inspection?

No. Gateway body inspection can interrupt an already-running Worker. Check the final policy outcome and the application's actual outcome separately.

Should I replace next(request) with fetch(request)?

Not to continue the user's original request. The documented continuation is next(request), called at most once. A normal fetch is an independent subrequest with different routing assumptions.

Is the beta free because all Zero Trust plans can use it?

Plan availability does not remove Workers usage billing or limits. Cloudflare says dispatched requests use standard Workers request billing. Check your account's plan and any additional services.

Is the example a tested production configuration?

No. It is an unexecuted diagnostic template for an authorised, controlled pilot. A response marker is not authentication and does not establish complete security or application correctness.

Sources & further reading

  1. Cloudflare changelog: Gateway–Workers public beta, 15 October 2026
  2. Cloudflare launch article: A fully programmable secure web gateway, 15 October 2026
  3. Cloudflare One: Integrate Workers overview
  4. Cloudflare One: Forward traffic and deployment contract
  5. Cloudflare One: Gateway context, identity and device posture
  6. Cloudflare One: Order of enforcement
  7. Cloudflare Workers: Current pricing and usage limits

Originally published . About our editorial updates.

Your next project deserves a better foundation.

Explore hosting built for your next chapter.

Explore hosting

Find your next answer.

Search published guides and articles.

Ctrl / ⌘ K to open · Esc to close