playsonmac
playsonmac
Explore posts from servers
CDCloudflare Developers
Created by playsonmac on 2/2/2025 in #workers-help
Websocket subprotocol results in Error: The script will never generate a response.
Websockets - sending subprotocols (auth token smuggling) results in Error: The script will never generate a response. Client:
const ws = new WebSocket(wsUrl, "potato");
const ws = new WebSocket(wsUrl, "potato");
Using hono for the worker:
app.get(
"/ws",
upgradeWebSocket((c) => {
const rawProtocols = c.req.header("sec-websocket-protocol");
console.log(rawProtocols);

return {
onMessage: (event) => {
console.log(event.data);
},
};
})
);
app.get(
"/ws",
upgradeWebSocket((c) => {
const rawProtocols = c.req.header("sec-websocket-protocol");
console.log(rawProtocols);

return {
onMessage: (event) => {
console.log(event.data);
},
};
})
);
Fails right away at the upgrade with Error: The script will never generate a response. on the server. This only happens if I send a subprotocol such as "potato" which automatically gets converted to the sec-websocket-protocol header as it should. Curiously I can see the header in the console log. Also tried with hc, same issue.
1 replies
CDCloudflare Developers
Created by playsonmac on 11/1/2024 in #pages-help
Nextjs multi-zone deployment?
Do pages support nextjs' multi-zone routing? If so, is there an article or a repo showcasing how one can host both an app (and a blog for example) on the same domain using cf pages and two different instances of nextjs?
1 replies