Hey everyone!
I have a CF Worker that serves as a REST API. I want to use this API from another CF Worker but without having to send a request over the Internet.
I read about Service Bindings and decided to try it out. The feature works from the fetch
handler, but not from the queue
handler:
Works
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const test = await env.api.fetch(request);
console.log(test.ok);
}
Doesn’t work
async queue(batch: MessageBatch<any>, env: Env): Promise<void> {
const request = new Request('/api/test');
const test = await env.api.fetch(request); // TypeError
console.log(test.ok);
}
Is this not supported?
Thanks in advance!