<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Raj</title>
    <description>The latest articles on DEV Community by Raj (@raj_d0814e615822b2781f996).</description>
    <link>https://dev.to/raj_d0814e615822b2781f996</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3814764%2Ff8d53873-06b2-4272-940c-9820faf00638.jpg</url>
      <title>DEV Community: Raj</title>
      <link>https://dev.to/raj_d0814e615822b2781f996</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raj_d0814e615822b2781f996"/>
    <language>en</language>
    <item>
      <title>Phantom CLS in Lighthouse: How to Hunt Down and Fix Invisible Layout Shifts</title>
      <dc:creator>Raj</dc:creator>
      <pubDate>Mon, 06 Jul 2026 03:15:07 +0000</pubDate>
      <link>https://dev.to/raj_d0814e615822b2781f996/phantom-cls-in-lighthouse-how-to-hunt-down-and-fix-invisible-layout-shifts-5b68</link>
      <guid>https://dev.to/raj_d0814e615822b2781f996/phantom-cls-in-lighthouse-how-to-hunt-down-and-fix-invisible-layout-shifts-5b68</guid>
      <description>&lt;h1&gt;
  
  
  Phantom CLS in Lighthouse: How to Hunt Down and Fix Invisible Layout Shifts
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Published on June 29, 2026 · 5 min read&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;By Raj Pawan Shukla&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;You run Google Lighthouse expecting a great performance score.&lt;/p&gt;

&lt;p&gt;Everything looks visually stable.&lt;/p&gt;

&lt;p&gt;Yet Lighthouse reports:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"Avoid large layout shifts."&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You reload the page several times, carefully watching every element. Nothing appears to move.&lt;/p&gt;

&lt;p&gt;So what's causing the poor &lt;strong&gt;Cumulative Layout Shift (CLS)&lt;/strong&gt; score?&lt;/p&gt;

&lt;p&gt;This is what I like to call &lt;strong&gt;Phantom CLS&lt;/strong&gt;—layout shifts that happen so quickly they're almost impossible to notice with the naked eye, yet Chrome and Lighthouse still detect them.&lt;/p&gt;

&lt;p&gt;While optimizing the Newport Fasteners ecommerce platform, I encountered exactly this problem. Here's how I tracked it down and fixed it.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Causes Phantom CLS?
&lt;/h1&gt;

&lt;p&gt;The two most common culprits are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Lazy-loaded images above the fold&lt;/strong&gt; – Images that should be visible immediately are unnecessarily deferred.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Client-side injected UI components&lt;/strong&gt; – JavaScript renders elements slightly after the initial HTML has already been painted, causing nearby content to shift.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both of these appeared during my investigation.&lt;/p&gt;




&lt;h1&gt;
  
  
  Case 1: The Lazy-Loaded Hero Banner
&lt;/h1&gt;

&lt;p&gt;The homepage featured a large promotional banner that was being lazy-loaded.&lt;/p&gt;

&lt;p&gt;On a fast internet connection, the image appeared almost instantly, so the layout shift was practically impossible to notice. However, Lighthouse consistently flagged it as a contributor to CLS.&lt;/p&gt;

&lt;p&gt;The underlying issue was simple:&lt;/p&gt;

&lt;p&gt;The browser didn't know how much space to reserve before the image loaded. When the image finally appeared, it pushed surrounding content just enough for Lighthouse to record a layout shift.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Fix
&lt;/h2&gt;

&lt;p&gt;For images that appear above the fold:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remove &lt;code&gt;loading="lazy"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;fetchpriority="high"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Preload the image&lt;/li&gt;
&lt;li&gt;Always specify explicit &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Before
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"hero-banner.jpg"&lt;/span&gt; &lt;span class="na"&gt;loading=&lt;/span&gt;&lt;span class="s"&gt;"lazy"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Promo"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  After
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"preload"&lt;/span&gt; &lt;span class="na"&gt;as=&lt;/span&gt;&lt;span class="s"&gt;"image"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"hero-banner.jpg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt;
    &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"hero-banner.jpg"&lt;/span&gt;
    &lt;span class="na"&gt;fetchpriority=&lt;/span&gt;&lt;span class="s"&gt;"high"&lt;/span&gt;
    &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"1200"&lt;/span&gt;
    &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"400"&lt;/span&gt;
    &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Promo"&lt;/span&gt;
&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After these changes, the layout shift for the hero banner disappeared completely.&lt;/p&gt;




&lt;h1&gt;
  
  
  Case 2: Render-Blocking UI Scripts
&lt;/h1&gt;

&lt;p&gt;The product pages still showed tiny layout shifts during the initial render.&lt;/p&gt;

&lt;p&gt;Using Chrome DevTools, I traced them to two JavaScript files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;df_add_to_cart_hyva.min.js&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;nouislider.min.js&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These scripts initialized the &lt;strong&gt;Add to Cart&lt;/strong&gt; section and the &lt;strong&gt;price range slider&lt;/strong&gt; shortly after the browser painted the initial HTML.&lt;/p&gt;

&lt;p&gt;Although the delay lasted only a fraction of a second, the components expanded after JavaScript execution, causing nearby elements to move.&lt;/p&gt;

&lt;p&gt;The movement was almost invisible to users—but Lighthouse still recorded it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Fix
&lt;/h2&gt;

&lt;p&gt;The solution required &lt;strong&gt;two changes together&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Reserve Layout Space
&lt;/h3&gt;

&lt;p&gt;Even before JavaScript executes, reserve enough space for the components.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.price-slider-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;60px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.add-to-cart-wrapper&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;48px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Defer Non-Critical JavaScript
&lt;/h3&gt;

&lt;p&gt;Instead of blocking HTML parsing, allow the browser to continue rendering while downloading JavaScript.&lt;/p&gt;

&lt;h3&gt;
  
  
  Before
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"df_add_to_cart_hyva.min.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"nouislider.min.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  After
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"df_add_to_cart_hyva.min.js"&lt;/span&gt; &lt;span class="na"&gt;defer&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"nouislider.min.js"&lt;/span&gt; &lt;span class="na"&gt;defer&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Using &lt;code&gt;defer&lt;/code&gt; alone does &lt;strong&gt;not&lt;/strong&gt; eliminate CLS. In fact, it can make layout gaps more noticeable if no space has been reserved. Stable layouts require both reserved space &lt;strong&gt;and&lt;/strong&gt; deferred script loading.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  How to Debug Phantom CLS
&lt;/h1&gt;

&lt;p&gt;Don't trust your eyes—trust the tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Chrome DevTools Performance Panel
&lt;/h2&gt;

&lt;p&gt;Record a page load and inspect the &lt;strong&gt;Experience&lt;/strong&gt; track.&lt;/p&gt;

&lt;p&gt;Chrome highlights exactly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which DOM elements shifted&lt;/li&gt;
&lt;li&gt;When the shift occurred&lt;/li&gt;
&lt;li&gt;How much they contributed to CLS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the fastest way to locate invisible layout shifts.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Web Vitals Extension
&lt;/h2&gt;

&lt;p&gt;Install the Web Vitals browser extension to log layout shifts in real time while interacting with your website.&lt;/p&gt;

&lt;p&gt;It makes identifying problematic components much easier during development.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Test on Throttled Connections
&lt;/h2&gt;

&lt;p&gt;Phantom CLS often hides behind fast hardware and local development environments.&lt;/p&gt;

&lt;p&gt;Switch Chrome DevTools to &lt;strong&gt;Fast 3G&lt;/strong&gt; or &lt;strong&gt;Slow 4G&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Many layout shifts that are invisible on broadband become immediately obvious under realistic network conditions.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Takeaway
&lt;/h1&gt;

&lt;p&gt;Core Web Vitals measure real user experience—not just what your page looks like after everything finishes loading.&lt;/p&gt;

&lt;p&gt;Even movements that last only a few milliseconds can make a page feel unstable and negatively impact your Lighthouse score.&lt;/p&gt;

&lt;p&gt;Fixing Phantom CLS requires changing how you think about rendering.&lt;/p&gt;

&lt;p&gt;Instead of focusing only on the final appearance of a page, think about the browser's journey from the very first paint to the fully interactive state.&lt;/p&gt;

&lt;p&gt;A few simple practices can prevent most layout shifts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reserve space before dynamic content loads.&lt;/li&gt;
&lt;li&gt;Avoid lazy-loading above-the-fold images.&lt;/li&gt;
&lt;li&gt;Prioritize hero assets using &lt;code&gt;fetchpriority&lt;/code&gt; and &lt;code&gt;preload&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Defer non-critical JavaScript.&lt;/li&gt;
&lt;li&gt;Always verify improvements using Chrome DevTools and Lighthouse.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Performance optimization isn't always about making pages faster—it's also about making them feel stable.&lt;/p&gt;

&lt;p&gt;Sometimes the hardest performance bugs are the ones users never consciously notice.&lt;/p&gt;




&lt;h2&gt;
  
  
  Have you encountered Phantom CLS?
&lt;/h2&gt;

&lt;p&gt;I'd love to hear about the trickiest layout shift issues you've debugged. Share your experience in the comments, and let's learn from each other's performance wins and challenges.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>performance</category>
      <category>google</category>
      <category>website</category>
    </item>
    <item>
      <title>How a Magento 2 Upgrade Broke Our Multi-Website Setup (And Why the Problem Wasn't Magento)</title>
      <dc:creator>Raj</dc:creator>
      <pubDate>Thu, 11 Jun 2026 02:36:57 +0000</pubDate>
      <link>https://dev.to/raj_d0814e615822b2781f996/how-a-magento-2-upgrade-broke-our-multi-website-setup-and-why-the-problem-wasnt-magento-2pd5</link>
      <guid>https://dev.to/raj_d0814e615822b2781f996/how-a-magento-2-upgrade-broke-our-multi-website-setup-and-why-the-problem-wasnt-magento-2pd5</guid>
      <description>&lt;p&gt;A few weeks ago, I was working on a Magento 2 upgrade for a project that hosts multiple websites under a single Magento installation.&lt;/p&gt;

&lt;p&gt;The upgrade itself went smoothly. Deployment completed successfully, Magento commands ran without errors, and our initial testing didn't reveal any major issues.&lt;/p&gt;

&lt;p&gt;A little later, however, we discovered that the secondary website was redirecting to the default website.&lt;/p&gt;

&lt;p&gt;What made this issue particularly interesting was that the root cause wasn't inside Magento at all.&lt;/p&gt;

&lt;p&gt;Project Setup&lt;/p&gt;

&lt;p&gt;The project contained two websites:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Default Website&lt;/li&gt;
&lt;li&gt;Secondary Website&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before the upgrade, both websites were serving different storefronts correctly.&lt;/p&gt;

&lt;p&gt;After the upgrade, the default website continued to work as expected, but requests to the secondary domain eventually started redirecting to the default website.&lt;/p&gt;

&lt;p&gt;Why the Issue Was Confusing&lt;/p&gt;

&lt;p&gt;What made this issue difficult to troubleshoot was that our initial testing passed.&lt;/p&gt;

&lt;p&gt;We didn't miss testing the secondary website. As part of our deployment verification, we tested both websites and both appeared to be working correctly.&lt;/p&gt;

&lt;p&gt;The redirect issue only surfaced later during additional testing.&lt;/p&gt;

&lt;p&gt;Because of this, we suspected that some form of caching might have been masking the problem during the first round of verification. It could have been browser cache, Cloudflare cache, or another layer serving cached responses.&lt;/p&gt;

&lt;p&gt;While we never conclusively identified which cache layer was involved, the delayed appearance of the issue created the impression that the deployment had been successful and that both websites were functioning normally.&lt;/p&gt;

&lt;p&gt;As a result, our investigation initially focused on whether something had changed after deployment rather than on the deployment itself.&lt;/p&gt;

&lt;p&gt;Checking Magento Configuration&lt;/p&gt;

&lt;p&gt;Since the issue involved website routing, Magento configuration became our first suspect.&lt;/p&gt;

&lt;p&gt;We reviewed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Websites&lt;/li&gt;
&lt;li&gt;Store Groups&lt;/li&gt;
&lt;li&gt;Store Views&lt;/li&gt;
&lt;li&gt;Base URLs&lt;/li&gt;
&lt;li&gt;Store configurations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything looked correct.&lt;/p&gt;

&lt;p&gt;The secondary website still existed, the domains were configured properly, and the store hierarchy matched what we expected.&lt;/p&gt;

&lt;p&gt;We also considered whether a configuration value had been changed accidentally after deployment, but nothing seemed out of place.&lt;/p&gt;

&lt;p&gt;At this point, Magento wasn't giving us any useful clues.&lt;/p&gt;

&lt;p&gt;Is the Redirect Really Coming From Magento?&lt;/p&gt;

&lt;p&gt;Instead of continuing to search through Magento configuration, we decided to answer a simpler question:&lt;/p&gt;

&lt;p&gt;Was the redirect actually happening inside Magento?&lt;/p&gt;

&lt;p&gt;To test this, we created a simple HTML file inside the "pub" directory:&lt;/p&gt;

&lt;p&gt;test.html&lt;/p&gt;

&lt;p&gt;When we accessed the file through both domains, it loaded successfully.&lt;/p&gt;

&lt;p&gt;This immediately told us that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DNS was working&lt;/li&gt;
&lt;li&gt;Domains were resolving correctly&lt;/li&gt;
&lt;li&gt;Nginx was serving requests correctly&lt;/li&gt;
&lt;li&gt;Requests were reaching the Magento "pub" directory&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nothing pointed to a DNS or web server routing issue.&lt;/p&gt;

&lt;p&gt;The PHP Test&lt;/p&gt;

&lt;p&gt;Next, we created a simple PHP file:&lt;/p&gt;

&lt;p&gt;&amp;lt;?php&lt;br&gt;
echo "PHP Test";&lt;/p&gt;

&lt;p&gt;This was where things became interesting.&lt;/p&gt;

&lt;p&gt;The behavior changed once PHP execution became involved.&lt;/p&gt;

&lt;p&gt;Static HTML files worked, but PHP-driven requests did not.&lt;/p&gt;

&lt;p&gt;That observation narrowed the investigation significantly. Since Magento relies on PHP, the issue appeared to be somewhere between PHP execution and Magento's website resolution process.&lt;/p&gt;

&lt;p&gt;Looking Beyond Magento&lt;/p&gt;

&lt;p&gt;At this point, Magento's configuration still looked correct, yet the behavior didn't make sense.&lt;/p&gt;

&lt;p&gt;We shifted our focus to the web server configuration and started reviewing how requests were being passed to Magento.&lt;/p&gt;

&lt;p&gt;One useful command during the investigation was:&lt;/p&gt;

&lt;p&gt;nginx -T&lt;/p&gt;

&lt;p&gt;This allowed us to inspect the final configuration Nginx was actually using.&lt;/p&gt;

&lt;p&gt;While reviewing the active configuration, we noticed that the settings responsible for identifying the Magento website were missing.&lt;/p&gt;

&lt;p&gt;One factor that delayed the investigation was that I didn't realize the project's "nginx.conf.sample" had been customized in the past.&lt;/p&gt;

&lt;p&gt;The multi-website setup had been implemented before I worked on this area of the project, and the Nginx configuration was historically maintained by another developer. Because of that, I initially treated "nginx.conf.sample" as a standard Magento file rather than a file containing project-specific customizations.&lt;/p&gt;

&lt;p&gt;That assumption turned out to be important.&lt;/p&gt;

&lt;p&gt;The Real Root Cause&lt;/p&gt;

&lt;p&gt;The breakthrough came when we compared the current configuration with what existed before the upgrade.&lt;/p&gt;

&lt;p&gt;During the Magento upgrade, "nginx.conf.sample" had been updated.&lt;/p&gt;

&lt;p&gt;The project previously contained custom multi-website configuration that relied on values such as:&lt;/p&gt;

&lt;p&gt;MAGE_RUN_CODE&lt;br&gt;
MAGE_RUN_TYPE&lt;/p&gt;

&lt;p&gt;These parameters tell Magento which website should handle an incoming request.&lt;/p&gt;

&lt;p&gt;Before the upgrade, Nginx correctly passed the website information to Magento.&lt;/p&gt;

&lt;p&gt;After the upgrade, those custom settings were no longer present.&lt;/p&gt;

&lt;p&gt;As a result, Magento could no longer identify the secondary website correctly and defaulted to the primary website instead, causing the unexpected redirects.&lt;/p&gt;

&lt;p&gt;In hindsight, the behavior made perfect sense.&lt;/p&gt;

&lt;p&gt;Magento wasn't broken.&lt;/p&gt;

&lt;p&gt;Magento was simply receiving incomplete information from the web server.&lt;/p&gt;

&lt;p&gt;The Fix&lt;/p&gt;

&lt;p&gt;Once we identified the missing configuration, the solution was straightforward.&lt;/p&gt;

&lt;p&gt;We restored the required parameters:&lt;/p&gt;

&lt;p&gt;fastcgi_param MAGE_RUN_CODE secondary_website_code;&lt;br&gt;
fastcgi_param MAGE_RUN_TYPE website;&lt;/p&gt;

&lt;p&gt;Then we validated and reloaded Nginx:&lt;/p&gt;

&lt;p&gt;sudo nginx -t&lt;br&gt;
sudo systemctl reload nginx&lt;/p&gt;

&lt;p&gt;The issue disappeared immediately.&lt;/p&gt;

&lt;p&gt;The secondary website started loading correctly, and requests were no longer redirected to the default website.&lt;/p&gt;

&lt;p&gt;Lessons Learned&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Don't Assume the Upgrade Is the Root Cause&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The problem appeared after the Magento upgrade, but Magento itself wasn't responsible.&lt;/p&gt;

&lt;p&gt;The upgrade indirectly caused the issue by replacing a configuration file that contained project-specific customizations.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Isolate Components&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The HTML and PHP tests were extremely valuable.&lt;/p&gt;

&lt;p&gt;By testing outside Magento, we were able to determine where the problem started and avoid spending even more time looking in the wrong place.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Multi-Website Setups Depend on Server Configuration&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In Magento multi-website environments, web server configuration is just as important as Magento configuration.&lt;/p&gt;

&lt;p&gt;Even with a perfectly configured Magento instance, missing "MAGE_RUN_CODE" and "MAGE_RUN_TYPE" values can break website routing.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Review Customized Files During Upgrades&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's easy to focus on code and database changes during an upgrade.&lt;/p&gt;

&lt;p&gt;However, projects often contain customized versions of files that ship with Magento. Those customizations should always be identified, documented, and reviewed during upgrade work.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;What initially looked like a Magento website configuration issue turned out to be a web server configuration problem caused by changes to a customized "nginx.conf.sample" file during the upgrade process.&lt;/p&gt;

&lt;p&gt;The investigation moved from Magento configuration checks to HTML testing, PHP testing, and finally Nginx configuration review before the actual cause became clear.&lt;/p&gt;

&lt;p&gt;In the end, the fix was only a few lines of configuration, but finding those lines required understanding exactly where the request flow was breaking.&lt;/p&gt;

&lt;p&gt;Sometimes the fastest way to solve a Magento problem is to stop looking at Magento and start looking at everything around it.&lt;/p&gt;

</description>
      <category>nginx</category>
      <category>softwareengineering</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
