Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

258
Vistas
How to use request location header to modify static site via Javascript?

Objective: I'm trying to add a pop-up on my pages tailored to the visitors country.

Tech: I have a static site hosted on Github Pages, with Cloudflare as CDN.

I'm using this Cloudflare managed worker to add the visitors country to their request.

How do I access this "cf-ipcountry" value from the request header in Javascript and do something with it?

--

Edit: If it's not possible to get it directly, could I use a Cloudflare worker to parse the request and modify the page load? Something like this (but instead of listening for an auth token I listen for the country code in the request header?)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Request headers are not exposed to client-side JavaScript.

Even if they were, the request from the browser to Cloudflare is a different request to the one from Cloudflare to Github Pages and the header you want is on the request that the browser doesn't have access to.

So: You can't.


You need server-side programming capabilities for this.

If you want to use the header added by Cloudflare then you need it on the server you are hosting the site on.

Otherwise, your minimum is a third-party GeoIP web-service that supports CORS (or the old, risky JSONP) that you can hit with Ajax.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda