Is there a way for the origin server to get the country code for the data center?

Dear Community Hello
I have a question about how the data center works.
Is there a way for the origin server to get the country code for the data center?
“CF-IPCountry” is the client country code, not the data center country code.
Deliver Japanese images to data centers in Japan.
I want to deliver English to English-speaking countries.

This is a special project
The game I’m playing has the ability to download images from the web and use them as textures in the game.
However, the URL cannot be generated dynamically.
You can’t even refer to the response header. All you can do is refer to the downloaded image.
So the server has to think about the country. The client will not tell.

I don’t know the algorithm that determines the data center.
You will probably be connected to a geographically close location.

Even if CF-IP Country is Japan, it may not be a Japanese data center.
For example, let’s say CF-IP Country is Japan and the data center is South Korea.
This is sending Japanese to Korea (not Japanese).

wrap up
Is there a way for the origin server to get the country code for the data center?
Is the data center connected geographically close?
Or will it cross countries?

I used Google Translate.

I’m pretty sure this would require a Worker to pass this to your server in a Request header. @judge and/or @matteo might be familiar with this.

Unfortunately, as far as I know, there is no easy way to get the country of a specific colo directly from the request. You can get the actual colo and then extrapolate it with a list of ICAO codes, but it’s not direct.

When using the worker that @sdayman mentioned you would need to pass the request.cf.colo variable back to the origin as a header or however else you want.

Here you can see all the connections stats and datacenter map: https://cloudflare.manfredi.io/

1 Like

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