Geo State Code as a header via workers


We try to get the state code additional header through worker.

The following code is used:

addEventListener('fetch', event => {
async function handleRequest(request) {
  request = new Request(request);
  request.headers.set("header1", "123");
  return await fetch(request);

On the server side we get the value “undefined” for the HTTP_STATE_CODE header. Tried different various IP addresses and countries, and it is always undefined.
The test header1 returns 123 properly.

Any idea why the state code is not filled?
We reached the support and they confirmed that value should be available on our plan (Professional) and advised to ask community for assistance.

Thank you!

Ohh dear!

No, that field is not available on Professional but requires a Business plan.

Is it described somewhere? Because in the main link there is nothing written about such a limitation.

Here is also a part of the convo on the ticket:

We asked:
“That means you confirm that the worker header should be available on the Professional plan?”

Cloudflare support response:
" All of the request properties found in the link below should be available on your plan:

This includes regionCode as well."

We spent hours after this response trying to figure our why it doesn’t work. It will be not fun in case it is simply not available for us.

In the old documentation, before Cloudflare revamped it and removed that information :slight_smile:

Thanks to @adaptive for making a PR to fix the documentation. The plan clarification should be rolled out shortly.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.