AWS Lambda Function for CORS proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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