# Switch to HTTPS?

**URL:** <https://forum.freecodecamp.org/t/switch-to-https/12725>\
**Category:** I Built This\
**Created:** [June 20, 2016, 1:39pm UTC](https://forum.freecodecamp.org/t/switch-to-https/12725 "2016-06-20T13:39:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kvanderkamp](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kvanderkamp/32/5113_2.png) [@kvanderkamp](https://forum.freecodecamp.org/u/kvanderkamp)\
**Post date:** [June 20, 2016, 1:39pm UTC](https://forum.freecodecamp.org/t/switch-to-https/12725/1 "2016-06-20T13:39:23Z")

</div>

What’s up fellow coders!

For my weather app, I decided to read the position from `navigator.geolocation` in JavaScript. However, modern browsers such as Chromium **stricly require** the page to be loaded over a secure HTTPS connection for this feature to work.  
This leads to issues when getting weather data from [OpenWeatherMap.org](http://OpenWeatherMap.org), who only serve their API over HTTP. To solve this and have my app work fully over a secure connection, I tried switching to [forecast.io](http://forecast.io), however their API doesn’t allow for Cross-Origin Requests. Both OpenWeatherMap and Forecast won’t work for this project.

Suggestions are welcome.

---

<div class="post-metadata">

**Author:** ![gogu87](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gogu87/32/5377_2.png) [@gogu87](https://forum.freecodecamp.org/u/gogu87)\
**Post date:** [June 20, 2016, 1:55pm UTC](https://forum.freecodecamp.org/t/switch-to-https/12725/2 "2016-06-20T13:55:08Z")

</div>

Well, you can also try getting coordinates by ip as backup. I haven’t had that sort of problem though. Tried on Opera (chrome works flawless and firefox jumps on the ip if i don’t allow geolocation) and it won’t work if i have the Opera ad block on. Maybe you have a similar problem.

---

<div class="post-metadata">

**Author:** ![Mizu](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/mizu/32/95363_2.png) [@Mizu](https://forum.freecodecamp.org/u/Mizu)\
**Post date:** [June 20, 2016, 2:14pm UTC](https://forum.freecodecamp.org/t/switch-to-https/12725/3 "2016-06-20T14:14:13Z")

</div>

Get your codepen HTTPS and the call to [forecast.io](http://forecast.io) in HTTPS also, this should resolve any issues you had with CORS !

---

<div class="post-metadata">

**Author:** ![kvanderkamp](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kvanderkamp/32/5113_2.png) [@kvanderkamp](https://forum.freecodecamp.org/u/kvanderkamp)\
**Post date:** [June 20, 2016, 2:23pm UTC](https://forum.freecodecamp.org/t/switch-to-https/12725/4 "2016-06-20T14:23:55Z")

</div>

The [forecast.io](http://forecast.io) API doesn’t send the Cross-Origin Request headers that are required to make API calls from the browser. It will not send this header regardless if it’s a HTTP or HTTPS request. The [forecast.io](http://forecast.io) API documentation specifically links to a JavaScript wrapper with PHP proxy as a workaround, which I don’t want to use for this project.

---

<div class="post-metadata">

**Author:** ![Mizu](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/mizu/32/95363_2.png) [@Mizu](https://forum.freecodecamp.org/u/Mizu)\
**Post date:** [June 20, 2016, 2:27pm UTC](https://forum.freecodecamp.org/t/switch-to-https/12725/5 "2016-06-20T14:27:11Z")

</div>

if you are using $.getJSON to make the api call, add ?callback=? at the end of your query. This will make a JSONP request instead that will work.

[Read up on JSONP here](http://api.jquery.com/jquery.getjson/)

---

<div class="post-metadata">

**Author:** ![kvanderkamp](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/kvanderkamp/32/5113_2.png) [@kvanderkamp](https://forum.freecodecamp.org/u/kvanderkamp)\
**Post date:** [June 20, 2016, 2:52pm UTC](https://forum.freecodecamp.org/t/switch-to-https/12725/6 "2016-06-20T14:52:45Z")

</div>

Thank you, I think JSONP is an ugly hack but I’ll use it for now.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 6:11pm UTC](https://forum.freecodecamp.org/t/switch-to-https/12725/7 "2021-06-01T18:11:48Z")

</div>


