Magento Asked by Borche Glafche on September 9, 2020
I tried
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
and tried for js cross orign from htaccess
<FilesMatch ".(js)$">
in the .htaccess. but I still have the Cors error. Does anyone know how to fix it?
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
Go to your site config file for example
nano /etc/apache2/sites-available/localmagento.com.conf
and add
Header set Access-Control-Allow-Origin "*"
as below
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/magento2/
ServerName localmagento.com
ServerAlias www.localmagento.com
<Directory /var/www/html/magento2/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Header set Access-Control-Allow-Origin "*"
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
and use a2enmod headers and then restart server.
Answered by Hitesh Agrawal on September 9, 2020
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
Answered by Rizwan Khan on September 9, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP