· Iren Saltali · architecture · 2 min read

Backend for Frontend With Cloudflare Workers

A BFF pattern that uses the gateway as the stable public contract while upstream services stay small and focused.

The short answer: A Worker-based BFF works best when the gateway owns client-facing routes, auth, and request shaping, and leaves domain logic inside downstream services.

When to read this

  • A web or mobile client needs a tailored API surface.
  • Several internal services power one frontend experience.
  • You want edge-side normalization of auth and headers before origin calls.

What matters in practice

  • Keep the BFF contract client-centric, not service-centric.
  • Use mapping to keep downstream APIs stable even if the client contract evolves.
  • Document the boundary between BFF composition and business logic clearly.

Concrete example

        {
        "serviceBindings": [
          { "alias": "hooks", "binding": "HOOKS" },
          { "alias": "target", "binding": "TARGET" }
        ],
        "paths": [
          {
            "method": "POST",
            "path": "/orders",
            "pre_process": { "binding": "hooks", "function": "before" },
            "integration": { "type": "service_binding", "binding": "target", "function": "run" }
          }
        ]
      }

The example above is intentionally small because the best gateway configs stay readable. Add only the route, auth, and mapping behavior you actually need.

How this maps to the current gateway

The current codebase already supports the behavior discussed here through its config schema, route matcher, and integration handlers. That is why this project is a good fit for reader-first examples: the docs and blog can point to real, implemented behavior instead of hypothetical gateway features.

What this product does not do

  • This repo does not implement full workflow orchestration inside the landing/blog repo.
  • A BFF pattern can still become a bottleneck if too much domain logic moves into the edge layer.

FAQ

Should the BFF call one service or many?

Either is fine, as long as the public contract stays coherent and the edge layer remains maintainable.

Is service binding better than proxying for a BFF?

It depends on whether you need Worker-to-Worker method calls or plain HTTP forwarding.

Last reviewed: March 6, 2026

Back to Blog

Related Posts

View All Posts »