Pavlin Petkov
Pavlin Petkov

Reputation: 1142

Github pages website is on HTTPS but Rest API is on HTTP

I have github pages website which makes request to a hosted server which is HTTP and my browser blocks it.

Its assignment for university so I don't really want to pay for HTTPS on the server and I can't use something else for the front-end as I have sent the url to my professor expecting that this is where my web app will be hosted.

Is there anything I can do, which doesn't involve paying that much money?

Upvotes: 7

Views: 5387

Answers (2)

J.S. Peterson
J.S. Peterson

Reputation: 3022

I encountered this same issue when making API calls. Here's an easy workaround:

  1. Get your api endpoint (for this example, let’s say http://api.catphotos.io/)
  2. Prepend the CORS API link https://cors-anywhere.herokuapp.com/ to your link
  3. Make sure to leave the http:// on your endpoint.
  4. Your new link should look like this: https://cors-anywhere.herokuapp.com/http://api.catphotos.io/
  5. Make your API calls with your new link!

Source: johnalcher.me

Upvotes: 15

Kevin Workman
Kevin Workman

Reputation: 42174

According to the GitHub Pages help docs:

HTTPS enforcement is required for GitHub Pages sites created after June 15, 2016 and using a github.io domain.

That means you can't disable the https:// redirect. You could use a custom domain which then leaves the https:// stuff up to you.

Or you could move the stuff from the other server to GitHub Pages, assuming it's not too big.

Upvotes: 0

Related Questions