Skip to content

Instantly share code, notes, and snippets.

@AustinWoetzel
Last active June 2, 2021 10:42
Embed
What would you like to do?
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