Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

122
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda