No 'Access-Control-Allow-Origin' Dark Sky

I am making Local Weather app. I decided to use dark sky API.When I try to fetch the data No ‘Access-Control-Allow-Origin’ error pops up in console. I did a bit of research and found on their page “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.”. How do I set up a proxy server or what should I do?

EDIT: I created proxy API service using apigee and it’s working

1 Like

Hi,
I got same issue now i am trying for proxy API service, how to create it can you please tell me some details.
I first created account which says
"Thank you for your interest in trying out our APIs! Someone from our support team will be in touch." but i didnt get any mail from them.

Sorry for late response. I don’t know why they didn’t send the mail to you. I received confirmation email and logged in with my account. Did you find some other way to solve your problem?

You can also use jsonp.

Check this pen and read the comments (they’re helpful): https://codepen.io/skycoder/pen/EmdVBL

2 Likes

Hey faleksic. Can you please tell me how you managed to get info from Dark Sky using proxy API with apigee. I tried and I’m getting the error - {“fault”:{“faultstring”:“Unexpected EOF at target”,“detail”:{“errorcode”:“messaging.adaptors.http.flow.UnexpectedEOFAtTarget”}}} . I suppose the problem is with the proxy I created but i have no idea what it is.

Put your API URL behind: https://cors-anywhere.herokuapp.com/ and the problem will be solved. Let us know if we can help you further :slight_smile:

1 Like