Magento – Magento 2 Access-Control-Allow-Origin

corsmagento2

I tried

 <IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"

and tried for js cross orign from htaccess

<FilesMatch "\.(js)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
in the .htaccess. but I still have the Cors error. Does anyone know how to fix it?

Best Answer

You can also set the cross-origin in app/etc/env.php by changing the following parameter.

  'x-frame-options' => 'CROSS-ORIGIN',

after changing flush your magento cache

php bin/magento c:f

Thanks

Related Topic