Skip to content

Commit da04b97

Browse files
committed
feat: update request handling to match Cloudflare's WebSocket example
- Modified the request processing logic to construct internal URLs for WebSocket connections, aligning with Cloudflare's container WebSocket example. - Ensured that the request method and headers are preserved in the new internal request format.
1 parent 91aa827 commit da04b97

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

worker/effect/services.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,16 @@ const ContainerRuntimeLive = Layer.effect(
875875
headers.set('X-User', input.username);
876876
headers.set('X-Session-Id', input.sessionId);
877877
headers.set('X-Tab-Id', input.tabId);
878-
return ready.container.fetch(new Request(input.request, { headers }));
878+
// Match Cloudflare's container WebSocket example: synthetic http://host (not the browser's https worker URL).
879+
// https://developers.cloudflare.com/containers/examples/websocket/
880+
const u = new URL(input.request.url);
881+
const internal = new URL(`${u.pathname}${u.search}`, 'http://localhost:8080');
882+
return ready.container.fetch(
883+
new Request(internal, {
884+
method: input.request.method,
885+
headers,
886+
})
887+
);
879888
},
880889
catch: toContainerFailure('Container error, please retry in a moment.', true),
881890
})

0 commit comments

Comments
 (0)