Once a DO is created, it does not move.

Once a DO is created, it does not move. I check where a DO is by fetching a /cdn-cgi/trace, then seeing the colo field
10 Replies
Sébastien Morel
maybe I miss something but is this endpoint kind of automatic on the DO ? https://durable-object/cdn-cgi/trace
Hard@Work
Hard@WorkOP5mo ago
GitHub
where-durableobjects-live/apps/worker/src/DO.ts at main · helloimal...
Tracking where Durable Objects are created, wherever you are in the world. - helloimalastair/where-durableobjects-live
Sébastien Morel
ha I see ok would it be correct to do the same approach to know where the worker is running? right now I did it within the DO, it seems to work, I suppose from within the worker it should work too ?
Hard@Work
Hard@WorkOP5mo ago
Assuming it is a Worker handling an incoming fetch request, I would just get the colo from request.cf.colo Then you don't have to do a fetch call at all
Sébastien Morel
ok so first big thanks, for the colo in the DO, I can see my DO is in SJC (currently in France, 140ms is more than ok) 🙂 I don't see any cf.colo in the request on the worker though
"cf-connecting-ip": "xxx",
"cf-ipcountry": "FR",
"cf-ray": "xxx",
"cf-visitor": "{\"scheme\":\"https\"}",
"cf-connecting-ip": "xxx",
"cf-ipcountry": "FR",
"cf-ray": "xxx",
"cf-visitor": "{\"scheme\":\"https\"}",
that's the CF headers I get
Hard@Work
Hard@WorkOP5mo ago
It's not in the headers, it is on the Request object itself Like:
export default {
async fetch(req, env, ctx) {
console.log("My colo is", req.cf.colo);
// Do stuff
}
}
export default {
async fetch(req, env, ctx) {
console.log("My colo is", req.cf.colo);
// Do stuff
}
}
Sébastien Morel
oh I need to see if I have that in Hono
Hard@Work
Hard@WorkOP5mo ago
app.post('/', async (c) => {
const colo = c.req.raw.cf?.colo
...
})
app.post('/', async (c) => {
const colo = c.req.raw.cf?.colo
...
})
Sébastien Morel
yes 🙂 modulo some types missing right away
anirudh
anirudh5mo ago
You can also see here: https://where.durableobjects.live
Tracking where Durable Objects are created, wherever you are in the world.
Want results from more Discord servers?
Add your server