CORS orgin error for requests in netlify functions

Hi,

        exports.handler = function(event,context,callback){
            let {longURL}= JSON.parse(event.body);
            let url = "https://cutt.ly/api/api .php?key={appKey}&short="+encodeURIComponent(longURL);
           const send =  body=>{
            callback(null,{
                statusCode:200,
                headers:{
                    'Access-Control-Allow-Origin': 'chrome-extension://naniojgmdmkbiohhclebmfemiioanclc',
                    'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept',
                    'Content-Type': 'application/json',
                    'Access-Control-Allow-Methods': '*',
                    'Access-Control-Max-Age': '2592000',
                    'Access-Control-Allow-Credentials': 'true',
                },
                body: JSON.stringify(body)
            });
           }
           const shortURL = ()=>{
               axios.get(url).then(res=>send(res.data)).catch(err=>send(err));
           }
        shortURL();
        }

I used the above lamda function. But when I tried to access it using the netlify url https://wonderful-cray-1fd516.netlify.com/.netlify/functions/cuttly. I am getting cors error error.

Access to fetch at ‘wonderful-cray-1fd516.netlify .com/.netlify/functions/cuttly’ from origin ‘chrome-extension://naniojgmdmkbiohhclebmfemiioanclc’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

How to resolve this error?

Hi,

Have you checked the actual response to see which headers were being returned and how your function is responding to the OPTIONS request?