Skip to content

Instantly share code, notes, and snippets.

@AustinWoetzel
Last active June 2, 2021 10:42
Show Gist options
  • Save AustinWoetzel/da808287f35effd2419ef44ed8593054 to your computer and use it in GitHub Desktop.
Save AustinWoetzel/da808287f35effd2419ef44ed8593054 to your computer and use it in GitHub Desktop.
AWS Lambda Function for CORS proxy
const axios = require('axios');
exports.handler = async (event) => {
const route = event.path
const request = {
url: 'https://secret-2--lcd--full.datahub.figment.io/apikey/xxxxxxxxxxxxxxxxxxxxxxxx' + route,
method: event.httpMethod,
data: event.body,
params: event.params
}
const response = await axios(request)
var res = {
"statusCode": 200,
"headers": {
"Access-Control-Allow-Origin":"*"
},
"body": (JSON.stringify(response.data)),
"isBase64Encoded": false
};
return res;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment