Is there a way to allow multiple cross-domains using the Access-Control-Allow-Origin
header?
I\'m aware of the *
, but it is too open. I rea
For information on how to configure multiple origins on Serverless AWS Lambda and API Gateway - albeit a rather large solution for something one would feel should be quite straightforward - see here:
https://stackoverflow.com/a/41708323/1624933
It is currently not possible to configure multiple origins in API Gateway, see here: https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors-console.html), but the recommendation (in the answer above) is:
The simple solution is obviously enabling ALL (*) like so:
exports.handler = async (event) => {
const response = {
statusCode: 200,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Credentials" : true // Required for cookies, authorization headers with HTTPS
},
body: JSON.stringify([{
But it might be better to do this on the API Gateway side (see 2nd link above).