The CORS error occurs because you have enabled the CORS in your Function code and also in the catalyst console so that when fetching the resource from the Appsail domain to the Functions domain throwing the CORS error. To resolve this, kindly remove the CORS-related code from your function and try fetching the resources again from the AppSail domain to the Functions domain.
After removing the CORS configuration from your function, try fetching the resources again, and this should resolve the CORS error.