If you going to build weather app or doing it right now hundred percent you encountered (or will do it) an issue. The issue
is No 'Access-Control-Allow-Origin' header is present on the requested resource
message in console when you try to fetch weather data from
dark sky api. It turns out weather provider have disabled cross-origin resource sharing (CORS)
on their servers. Actually you can read about it here.
Below is excerption from faq section
To prevent API key abuse, you should set up a proxy server to make calls to our API behind the scenes. Then you can provide forecasts to your clients without exposing your API key.
- fork it
git clone
to your machineyarn install
- register at https://darksky.net/dev/ to get you api key
- change
.env.exampe
to.env
and put you api key as value toAPI_KEY
. - run it locally with
yarn start
before your weather app - deploy your proxy-server to heroku or now when your weather app is ready for production (you need to run proxy-server live in internet in order for your weather app to work in production)
- make calls through the proxy with the format: https://yourURL.herokuapp.com/api/v1/json?lat=50.1234&lon=-116.1234