https://...cloudworkstations.dev/... or https://ir-web.vercel.app/..., not your production domain https://snipgeek.com.
This isn't just annoying; it's a symptom of a deeper technical problem that can fragment your comment base and ruin the user experience. We recently faced this issue firsthand. This is a transparent case study of its cause, our various repair attempts, and the final solution that ultimately resolved the problem.
http://localhost:3000 or https://...cloudworkstations.dev.https://ir-web.vercel.app.https://snipgeek.com.NODE_ENV to Domain Nameprocess.env.NODE_ENVNODE_ENV was "production". This failed. We quickly realized that preview deployments on Vercel also run in production mode, so the problem persisted.
localhost, cloudworkstations.dev, or vercel.app, it's impossible for it to register the wrong URL.
We implemented this directly within the PostComments.tsx component by checking window.location.hostname.
'use client';
// ...
const productionHostname = 'snipgeek.com'; // Final production domain
export function PostComments({ article }: PostCommentsProps) {
const [shouldLoad, setShouldLoad] = useState(false);
const commentsRef = useRef<HTMLDivElement>(null);
useEffect(() => {
// Observer for lazy-load
const observer = new IntersectionObserver(([entry]) => {
// When the component enters the viewport...
if (entry.isIntersecting) {
// ...check if the hostname is the production domain.
if (window.location.hostname === productionHostname) {
setShouldLoad(true);
}
observer.disconnect(); // Stop observing after the check.
}
});
if (commentsRef.current) observer.observe(commentsRef.current);
return () => observer.disconnect();
}, []);
if (!shouldLoad) {
// Display a placeholder if not on the production site
return (
<div ref={commentsRef} className="text-center ...">
<p>Comments are only available on the production site (snipgeek.com).</p>
</div>
);
}
// If on the production site, render Disqus with the correct URL
const canonicalUrl = `https://${productionHostname}/blog/${article.slug}`;
return (
<DiscussionEmbed
shortname={disqusShortname}
config={{ url: canonicalUrl, ... }}
/>
);
}
This approach is very specific: it checks where the user is, not just the mode the application is running in.
snipgeek-com for the final production.
Loading Conversation...