Skip to content

Instantly share code, notes, and snippets.

@wktk
Last active August 23, 2018 06:02
Show Gist options
  • Save wktk/2d53171aeab6956df141aaa52253c977 to your computer and use it in GitHub Desktop.
Save wktk/2d53171aeab6956df141aaa52253c977 to your computer and use it in GitHub Desktop.
Add CORS headers to HTTP responces with AWS Lambda for API Gateway
const axios = require('axios');
exports.handler = async (event) => {
const response = await axios.get(process.env.ENDPOINT_URL, { params: event.queryStringParameters });
return { statusCode: 200, headers: { "access-control-allow-origin": "*" }, body: JSON.stringify(response.data) };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment