Best approach to expose internal Payload instance to another Cloudflare Worker using Service Bindings? #14735
AliSananS
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey team,
I’m experimenting with a Worker-native setup using Payload + @opennextjs/cloudflare.
Architecture goal:
Cloudflare Workers allow this pattern: a Worker can expose methods and another Worker can call them like normal functions. For example:
Service bindings
Custom worker with opennext
Then from a different frontend Worker:
This works perfectly for simple functions.
What I’m trying to do
Expose a Payload instance from the CMS Worker so the frontend Worker can call internal APIs directly:
getPayload()instanceProblem
When exporting the Payload instance in the custom Worker:
file-type,sharp, Node streams, etcEven if I don’t use these features (image processing disabled), simply exposing the instance causes bundling issues.
Questions
Is this pattern unsupported on purpose?
i.e. Should Payload only be accessed through HTTP routes when deployed to Workers?
Is there a recommended way to expose internal operations from Payload Worker → another Worker, beyond HTTP endpoints?
If we want a fully Worker-native monorepo:
What’s the best strategy to avoid dependency/bundling hell?
Context
I’ve already discussed this with the
@opennextjs/cloudflareteam.Their architecture allows splitting concerns across Workers, and service bindings do not add extra request counts.
Payload on Workers is already in a great place, especially with current work happening around OpenNext + Cloudflare runtime.
Just looking to understand whether direct Worker-to-Worker service access (without public fetch endpoints) is a realistic first-class approach or fundamentally against the current architecture.
NOTE: Yes, there is an easy option to make fetch requests to the payload worker using
env.CMS.fetch("/api/query"), but I'm trying to use the local API as it is easier to query data compared to Rest-API.This method still has zero latency as a service method call.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions