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

126
Vistas
Do html redirect based on header request

I have near zero html and/or javascript experience and I'm finding so little information on this topic that I suspect I've got a fundamental misunderstanding on what I'm trying to do. But hey, software developers are somehow fungible so this ended up on my plate.

I've got a git project that includes several files. It looks like this: git repo:

  • index.html
  • my_data.json
  • my_data.html
  • .github/workflows
    • some_workflow.yaml
  • some_folder
    • some_other_file.json

I want to publish this on github-pages, which expects the page to be at index.html. When a user does a request to the github-pages url the files that get returned should be based off the request header that the user uses.

For example:

  • Navigating to the webpage http://my-org.github.io/my-project in a web browser would end up at the index.html file and should be redirected to my_data.html.

  • curl -H "Accept: application/json" "http://my-org.github.io/my-project" should return the my_data.json file.

  • A real nice bonus would be if I could navigate to http://my-org.github.io/my-project.json and get the json file

Redirecting to the my_data.html file by setting up a meta <http-equiv="refresh" content="0; url='./my_data.html'"> seems pretty standard but I can't figure out how to do the json part. Most tutorials specify what content negototiation is but then get all hand-wavey at the implementation or refer to API frameworks that have it all baked in. Is there some kind of javascript if statement I could use to handle the TWO mime-types I expect to handle?

about 4 years ago · Juan Pablo Isaza
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