<?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: Sujit Chanda</title>
    <description>The latest articles on DEV Community by Sujit Chanda (@sujit_chanda_223531a0bf06).</description>
    <link>https://dev.to/sujit_chanda_223531a0bf06</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3748653%2F5251d440-43ca-4f80-862c-b9d9010d0752.jpg</url>
      <title>DEV Community: Sujit Chanda</title>
      <link>https://dev.to/sujit_chanda_223531a0bf06</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sujit_chanda_223531a0bf06"/>
    <language>en</language>
    <item>
      <title>🚀 How I Fixed Canonical &amp; Indexing Issues on My React SPA (Cloudflare Pages + Custom Domain)</title>
      <dc:creator>Sujit Chanda</dc:creator>
      <pubDate>Mon, 02 Feb 2026 18:36:17 +0000</pubDate>
      <link>https://dev.to/sujit_chanda_223531a0bf06/how-i-fixed-canonical-indexing-issues-on-my-react-spa-cloudflare-pages-custom-domain-p3g</link>
      <guid>https://dev.to/sujit_chanda_223531a0bf06/how-i-fixed-canonical-indexing-issues-on-my-react-spa-cloudflare-pages-custom-domain-p3g</guid>
      <description>&lt;p&gt;I recently launched a small browser-based utility platform built with React and hosted on Cloudflare Pages.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Sitemap submitted&lt;/li&gt;
&lt;li&gt;Robots.txt configured&lt;/li&gt;
&lt;li&gt;Google Search Console verified&lt;/li&gt;
&lt;li&gt;Pages discovered&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But after 2 weeks…&lt;br&gt;
Only 1 page was indexed.&lt;/p&gt;

&lt;p&gt;The rest showed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“Duplicate, Google chose different canonical than user”&lt;/li&gt;
&lt;li&gt;“Discovered – currently not indexed”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s what was actually wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I had both domains active:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://optipress.in" rel="noopener noreferrer"&gt;https://optipress.in&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.optipress.in" rel="noopener noreferrer"&gt;https://www.optipress.in&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Live&lt;/li&gt;
&lt;li&gt;SSL enabled&lt;/li&gt;
&lt;li&gt;Returning 200 status&lt;/li&gt;
&lt;li&gt;Serving identical content&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I assumed Cloudflare Pages would automatically handle canonical preference.&lt;/p&gt;

&lt;p&gt;It didn’t.&lt;/p&gt;

&lt;p&gt;Google saw two hosts serving identical pages and started choosing its own canonical.&lt;/p&gt;

&lt;p&gt;For a new domain with zero authority, that slows everything down.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Was Happening Internally&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Search Console showed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User-declared canonical → non-www&lt;/li&gt;
&lt;li&gt;Google-selected canonical → www&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This split signals and delayed indexing.&lt;br&gt;
For a brand new SPA, that’s deadly.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;- Force a Single Host (301 Redirect)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Cloudflare → Rules → Redirect Rules:&lt;br&gt;
Condition:&lt;br&gt;
Hostname equals &lt;a href="http://www.optipress.in" rel="noopener noreferrer"&gt;www.optipress.in&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Action:&lt;br&gt;
Redirect to &lt;a href="https://optipress.in$%7Buri%7D" rel="noopener noreferrer"&gt;https://optipress.in${uri}&lt;/a&gt;&lt;br&gt;
Status: 301&lt;/p&gt;

&lt;p&gt;After deploying, www permanently redirects to non-www.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add Canonical Tag&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Inside &lt;code&gt;&amp;lt;head&amp;gt;: &amp;lt;link rel="canonical" href="https://optipress.in/" /&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And for every route:&lt;br&gt;
&lt;code&gt;&amp;lt;link rel="canonical" href="https://optipress.in/specific-page" /&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Purge Cloudflare Cache&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After redirect change, purge everything.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Re-Request Indexing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Search Console:&lt;br&gt;
Inspect URL&lt;br&gt;
Request indexing again&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SPA-Specific Observation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;My site is a pure React SPA:&lt;br&gt;
&lt;code&gt;&amp;lt;div id="root"&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Minimal initial HTML&lt;/li&gt;
&lt;li&gt;Content rendered via JS&lt;/li&gt;
&lt;li&gt;Slower indexing for new domains&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lesson learned:&lt;br&gt;
If you’re launching a JS-heavy site, domain consolidation matters even more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I Learned&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Always choose one primary host early&lt;br&gt;
Don’t assume hosting platforms auto-handle canonical logic&lt;br&gt;
New domains + SPAs = slower indexing&lt;br&gt;
Fix technical structure before chasing backlinks&lt;/p&gt;

&lt;p&gt;Check out : &lt;a href="https://optipress.in" rel="noopener noreferrer"&gt;https://optipress.in&lt;/a&gt;&lt;/p&gt;

</description>
      <category>google</category>
      <category>react</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
