crossorigin uses https, but will request the http version of openweathermap. Chrome wants everything secure (https), but it doesn’t matter if crossorigin (on their side) use http.
I have my current location : lat + long because I have my https request https://codepen url…
I wanna concatenate this coords with my API so I change my url API and its working when I console log because its grab my current lat and long.
But another problem in my console appear : so the aleart dont work.
Crossorigin is live. Codepen is messing things up again. You have a few spaces in the link: var api = "https://crossorigin.me/http://api.openweathermap.org/data/2.5/weather? lat="+lat+"&lon="+long+"&appid=ba7df19993124c71c649b28937220639";. Right between weather? and lat.
It is impossible to see this (at least for my screen size) thanks to Codepen continuing on a new line.
Anyway, to sum up if someone have the same problem as me. There is 2 methods !
You wanna use the navigator.geolocation function directly :
Guys If you using Google Chrome when you calling your browser by using the navigator.geolocation you have to have an HTTPS request so you have to turn codpen from HTTP://codepen… to HTTPS://codpen…
And if you use HTTPS for codepen you will need to use it for the url weather API.
For that add :
Add https://crossorigin.me/ to the var api:
so you have this. var api = "https://crossorigin.me/http://api.openweathermap.org...
if you dont wanna change this stuff and stay on HTTP request (without the “s”)
Stay on HTTP://codepen
Stay on HTTP:// your weather api url
Thanks. I figured out that using a different proxy might work & have tried with this proxy also. But no luck! I think, I will have to settle with apixu web service.
Is there a way to cure this problem in the long run, or should we maybe change the API we use, and maybe even change the suggested API (openweathermap) in the challenge description itself? It is pretty discouraging for anyone who tries the challenge and doesn’t know that much about protocols, tricks and gotchas.
EDIT: After trying more weather APIs than I can count my fingers, I’ve come to a conclusion that openweathermap is a good first choice for this challenge/project after all. There are free APIs out there with https support, even with much better documentation and you should surely check them out, but I’ve had some serious troubles getting the right response for my coordinates, a lot of servers were just sending me the wrong info on each request.
Good luck to everyone who is doing this project, and keep on trying, you will learn A LOT from it!