jakeherp / darksky-proxy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

darksky-proxy

A serverless proxy for Dark Sky API

Motivation

If you try to use the Dark Sky API from a web browser you'll get an error, "No 'Access-Control-Allow-Origin' header is present on the requested resource". That's because Dark Sky don't allow cross-origin requests to avoid clients exposing their API keys.

You can read more about it in the official FAQ.

Solution

To make requests to the Dark Sky API from a web browser (client) we can use a proxy (server). The client makes requests to the proxy (which allows CORS) and the proxy resends these requests to the Dark Sky API, adding the API key to the request. When the API answers the request made by the proxy, the proxy resends the API response to the client.

This proxy can be hosted for free using Netlify Functions with one click on the following button.

Deploy to Netlify

About

License:MIT License


Languages

Language:JavaScript 100.0%