TransWikia.com

How to setup Access_Control_Allow_origin & From origin blocked by CORS in Nginx for Mageno 2 multi-Website store?

Magento Asked on November 20, 2021

My main website store URL: test.website.in

Second website store URL : grocery.website.in

Initially, i developed multi-website in the localhost, and its working also but after move to live server main website working but second website store not working.

enter image description here

.htaccess:

SetEnvIf Host grocery.website.in* MAGE_RUN_CODE=grocery
SetEnvIf Host grocery.website.in* MAGE_RUN_TYPE=website

Note : Followed this tutorial still facing issues.

3 Answers

You need to set up CSP in your website. Check this Magento CSP doc

Create csp_whitelist.xml in your module loading the second website inside etc folder

<?xml version="1.0"?>
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
    <policies>
        <policy id="font-src">
            <values>
                <value id="your-test-website" type="host">test.website.in</value>
            </values>
        </policy>
    </policies>
</csp_whitelist>

Answered by Afreen Sheikh on November 20, 2021

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

enter image description here

Answered by Sanaullah Ahmad on November 20, 2021

Go to Content->Design->configurations

Click on edit link against your website.

apply a different them for each website. enter image description here

now run these commands.

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento setup:static-content:deploy -f

php bin/magento c:f

Answered by Sanaullah Ahmad on November 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP