Merge pull request #294 from reuters-graphics/jon-referral-fetch

Don't fetch referrals on non-dotcom domains
This commit is contained in:
Jon McClure 2025-04-24 18:05:39 +01:00 committed by GitHub
commit e271c4342d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
'@reuters-graphics/graphics-components': patch
---
Don't fetch referrals on non-dotcom domains

View file

@ -67,6 +67,9 @@
let referrals: Article[] = $state([]);
const getReferrals = async () => {
if (typeof window === 'undefined') return;
// fetch only reliably works on prod sites
if (window?.location?.hostname !== 'www.reuters.com') return;
const isCollection = Boolean(collection);
const API = isCollection ? COLLECTION_API : SECTION_API;
try {