Khafra
Khafra
Explore posts from servers
CDCloudflare Developers
Created by Khafra on 7/29/2024 in #workers-help
websocket request to durable object does not contain upgrade header
I have a weird issue. I deployed a project using durable objects to namespace.name.workers.dev and setup a worker route to a domain (ie. example.com) Everything works fine on the workers.dev domain, but when trying to connect to example.com it doesn't work with the error below. I've confirmed the browser is sending the header, but it's not being received by the fetch handler. Worker tried to return a WebSocket in a response to a request which did not contain the header "Upgrade: websocket"."
function handleApiRequest (request: Request, env: Env) {
const id = env.do.idFromName('default')
const roomObject = env.do.get(id)
return roomObject.fetch(request) // new Request(request.url, request) also does not work
}
function handleApiRequest (request: Request, env: Env) {
const id = env.do.idFromName('default')
const roomObject = env.do.get(id)
return roomObject.fetch(request) // new Request(request.url, request) also does not work
}
does anyone know why this isnt working?
8 replies
CDCloudflare Developers
Created by Khafra on 7/2/2024 in #workers-help
check if fetch request returned a cached response?
In a worker if I have a fetch request:
const response = await fetch('...', {
// ...
cf: {
cacheTtl: 1 * 60 * 15, // 15m
cacheEverything: true
}
})
const response = await fetch('...', {
// ...
cf: {
cacheTtl: 1 * 60 * 15, // 15m
cacheEverything: true
}
})
is it possible to determine if it's a cache hit?
2 replies
CDCloudflare Developers
Created by Khafra on 3/6/2023 in #workers-help
canceled outcome
I'm using a worker as a discord http interaction bot, but came across a problem when i need to defer a reply. Deferring is basically telling discord that you need a more time to send a reply, rather than the 3 seconds. so after it's deferred, discord closes the connection, as its expecting another request later on, which to my best guess, causes the worker to stop. is it possible to keep the worker open after this, or are there any clever workarounds?
3 replies