No Request in Server Container on Magento 2

When setting up Server Side Tracking for your Magento 2 website, you might encounter an issue where no requests are reaching the server container. This problem often arises due to a CORS (Cross-Origin Resource Sharing) rule in Magento, which can block outgoing requests from your hosting.

magento-cors-error-server-side-tracking

Understanding CORS in Magento

Magento implements CORS rules as a security measure to prevent cross-site scripting attacks. This means it restricts how resources on a web page can be requested from another domain than the one from which the first resource was served. Essentially, if your Magento hosting is blocking outgoing requests, it's likely due to these CORS rules.

How To Spot the CORS Error?

To check if you have a CORS Error, go to your website -> inspect -> Network tab. Search for your subdomain. If you see "Scrit Origin When Cross Origin" than you have a CORS Error.

Solution: No Request Server Container on Magento 2

To resolve this, adjust your web hosting's .htaccess file by adding:

<IfModule mod_headers.c>

Header add Access-Control-Allow-Origin "https://*.yourdomain.com"

</IfModule>

Make sure to replace "https://*.yourdomain.com" with your actual (top level) domain. This adjustment ensures that requests from your subdomain are permitted, bypassing the CORS restrictions that might be in place.

More info: thread on CORS policy.

By methodically following these steps, you should be able to resolve the no-request issue in your Magento 2 setup for Server Side Tracking. If the problem persists, reviewing the policy directives might provide insight into which domains are allowed and which are not, allowing for further troubleshooting.

Wrapping Up

These are the main reasons why you see no request in Server Container with a Magento 2 website. If your issue isn't listed here or if you've discovered another cause relevant to other users, send us a support ticket.