cloudflare / cloudflare/workerd

[FEATURE] Expose Workers Cloudflare Region

Open
#1,036 1 comment 5 reactions 1 assignee Claimed by @workers-devprod View on GitHub
feature request types
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

Right now if I want to know from which cloudflare region any workers instance has been invoked from I need to use something like this

```javascript
export default {
async fetch(request) => {
const res = await fetch('https://cloudflare-dns.com/dns-query', {
method: 'OPTIONS',
});
let region = res.headers.get('cf-ray').split('-')[1]; // LHR
}
}
```

Would it be possible to expose cloudflare workers location perhaps from the Environment variables

```javascript
export default {
async fetch(request, { CF_REGION }) => {
console.log(CF_REGION); // LHR
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.