Cors enabled but continue failing

I have an API using api gateway + lambdas (python), I have the issue of getting the No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
In my yml file i already have enabled cors and added the headers to the response of the lambda function but I’m still getting the same error, I don’t know what else needs to be done

Here is the example of my function definition in the yml file and the response headers of the lambda

handler: handler.function_name 
        - http:
            path: function-name
            method: any
            private: true
            cors: true

and the lambda response

response = {
    "headers": {
       'Access-Control-Allow-Headers': 'Content-Type',
       "Content-Type": "application/json",
       "Access-Control-Allow-Origin": "*"
    "statusCode": 200,
    "body": json.dumps(answer, indent=4, sort_keys=True, default=str)

I don’t know what else is missing as I’ve followed the examples here:

Any help is really appreciated.