Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!