Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Expose Workers Cloudflare Region #1036

Open
ghost opened this issue Aug 18, 2023 · 1 comment
Open

[FEATURE] Expose Workers Cloudflare Region #1036

ghost opened this issue Aug 18, 2023 · 1 comment
Assignees
Labels
feature request Request for Workers team to add a feature types Related to @cloudflare/workers-types

Comments

@ghost
Copy link

ghost commented Aug 18, 2023

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
  }
}
@ghost ghost added the types Related to @cloudflare/workers-types label Aug 18, 2023
@ghost ghost assigned workers-devprod Aug 18, 2023
@naegelin
Copy link

This feature is useful for:

  1. sub-requests that need to optimize RTT by talking to region-locked servers (User is from italy, sub request goes to italian server)
  2. conducting sub requests inside the GDPR zone to GDPR region locked servers. (User hits a worker in GDPR zone, sub requests guaranteed to stay in GDPR zone)

@jasnell jasnell added the feature request Request for Workers team to add a feature label Jul 31, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Jul 31, 2024
@andyjessop andyjessop moved this from Untriaged to Other in workers-sdk Aug 7, 2024
@andyjessop andyjessop removed this from workers-sdk Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for Workers team to add a feature types Related to @cloudflare/workers-types
Projects
None yet
Development

No branches or pull requests

3 participants