ga-dc / wdi5-project3

Project 3
0 stars 5 forks source link

Problem with mixed-content requests on heroku (https vs http) #72

Closed nclevine closed 9 years ago

nclevine commented 9 years ago

I am getting blocked ajax API requests when I try to make them from the heroku deployed version of my app. The problem is that it is a mixed-content request, meaning that my page is https, but the requests are to http URLs and are being blocked due to the "security risk". Unfortunately, some of the APIs simply don't work with https, they need to be http. All the solutions I have found online simply ask me to make all the requests https, but that's not an option. Any alternative ideas?

RobertAKARobin commented 9 years ago

Can you paste the contents of the error message?

nclevine commented 9 years ago

application-586cf86ad9f2e35d27dd4e47ca2f7067075f6334087fca4fd33ab77e732551bf.js:26 Mixed Content: The page at 'https://rocky-wildwood-9121.herokuapp.com/spaces/1' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://scrapi.org/search/magritte'. This request has been blocked; the content must be served over HTTPS.

adambray commented 9 years ago

I'm pretty sure the correct answer to this is to implement the external API requests from your backend, and then make an HTTPS AJAX request from JS to your backend.

mattscilipoti commented 9 years ago

Try using https in your browser for the url to your app.

mattscilipoti commented 9 years ago

Sorry. I read that backwards. Give me a sec.

nclevine commented 9 years ago

ok, i guess i will reroute all my apis thru the backend after all. the one that's already doing that is working fine and the url in my rails controller is http. thanks!

mattscilipoti commented 9 years ago

I recommend following Adam's advice (which appeared as I sent mine). You should be using https. Some api's are not allowing you too. Therefore, you need to perform them in your backend. You may be able to use "http" instead of "https" to access your heroku app, but that will probably cause warnings from the api's that are using https.

nclevine commented 9 years ago

nonetheless i am curious how to control whether a heroku app is http or https...

nclevine commented 9 years ago

thanks everyone