We uses KeyCdn to use cdn feature for magento 2. We use push zone for one of our website for testing. KeyCdn working fine except modal popup CORS issue.
We are facing below error.
Access to XMLHttpRequest at 'cdn.xxx.keycdn.net/pub/static/frontend/Abc/xyz/en_US/Magento_Ui/templates/modal/modal-popup.html' from origin 'www.xyz.org' 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.
I enabled CORS from KeyCdn panel but it was not resolved our issue. We read some blogs to allow CORS in magento 2 and put below code in .htaccess files but it was also not working.
MAGNETO_ROOT/pub/.htaccess
<IfModule mod_headers.c>
############################################
## Prevent clickjacking
#Header set X-Frame-Options SAMEORIGIN
## Put by developer
<FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js|html|json)">
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With"
Header set Access-Control-Allow-Methods "POST, GET, OPTIONS"
</FilesMatch>
## End
</IfModule>
Please help me, how to resolve CORS issue.