A page that fetches its own data via JavaScript worked fine on the live production domain but failed to load anything on a staging subdomain.
Hardcoded Absolute URLs Break Cross-Origin Testing on Staging
⚡ Quick Fix (TL;DR)
The Culprit: The script's fetch URL was hardcoded to the production domain rather than a relative path, making it a genuine cross-origin request once loaded from staging – confirmed directly via a CORS error in the browser console.
The Fix: Changing the hardcoded absolute URL to a relative path let the browser resolve it to whichever domain is actually serving the page – same-origin on both staging and production, no CORS involved on either. This is a strictly better pattern than the original, not just a staging workaround.
// Wrong — hardcoded absolute URL, breaks on any other domain:
var ERRORS_URL = 'https://zu2b.com/zu2b-web-error-guide.json';
// Right — relative path, resolves to whichever domain serves the page:
var ERRORS_URL = '/zu2b-web-error-guide.json';Tagged in :
More from the field
Bisect to an Empty Baseline Before Trusting Any Single Theory
.
Multiple plausible-sounding theories for a bug each turned out to be wrong when actually tested – time was spent building fixes…
A Security Dashboard’s Activity Log Can Lag a Full Day Behind Real Time
.
Trying to check a security tool’s activity log for an event that had just happened showed nothing at all.