Skip to content

[FEATURE] Expose Workers Cloudflare Region #1036

Open
@ghost

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

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

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

Metadata

Metadata

Labels

feature requestRequest for Workers team to add a featuretypesRelated to @cloudflare/workers-types

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions