AWS API Gateway - CORS + POST not working

前端 未结 9 1810
一生所求
一生所求 2020-12-01 10:34

CORS is really driving me crazy and I\'m really out of ideas as of what to try to make it work.

I have created a simple APIG Api with 1 resource cal

9条回答
  •  借酒劲吻你
    2020-12-01 11:11

    If you are using proxy integration in API Gateway, then enabling CORS from API Gateway doesn't work. You have to set the Header 'Access-Control-Allow-Origin' from your Lambda code itself.

    Its mentioned in the doc.

    Python code sample:

        response = {
            'statusCode': 200,
            'headers': {
                'Access-Control-Allow-Origin': '*'
            },
            'body': json.dumps({'message': 'CORS enabled')
        }
        return response
    

提交回复
热议问题