TryGhost/Ghost · error · Error
Failed to fetch site data
Error message
Failed to fetch site data
What it means
The comments-ui site.settings() method GETs the Ghost Content API settings endpoint (built via contentEndpointFor with the apiKey). If the response is not ok, it throws this generic message. This loads site-level config (title, labs flags, etc.) needed to render the comments widget.
Source
Thrown at apps/comments-ui/src/utils/api.ts:52
// To fix pagination when we create new comments (or people post comments
// after you loaded the page), we need to only load comments created AFTER the page load
let firstCommentCreatedAt: null | string = null;
const api = {
site: {
settings() {
const url = contentEndpointFor({resource: 'settings'});
return makeRequest({
url,
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
}).then(function (res) {
if (res.ok) {
return res.json();
} else {
throw new Error('Failed to fetch site data');
}
});
}
},
member: {
identity() {
const url = endpointFor({type: 'members', resource: 'session'});
return makeRequest({
url,
credentials: 'same-origin'
}).then(function (res) {
if (!res.ok || res.status === 204) {
return null;
}
return res.text();
});
},
View on GitHub (pinned to 47d8b0e2ad)
Solutions
- Verify the data-api-key and data-api-url attributes on the comments-ui script tag match the Ghost integration's Content API key and URL.
- Check the Network tab for the settings GET status and response.
- Ensure the Ghost site allows CORS from the page origin where comments-ui is embedded.
- Confirm the Ghost instance is online and the Content API is enabled.
Defensive patterns
Strategy: validation
Validate before calling
function isCommentsApiConfigured(apiUrl: string | undefined, apiKey: string | undefined): boolean {
return typeof apiUrl === 'string' && apiUrl.length > 0
&& typeof apiKey === 'string' && apiKey.length > 0;
} Try / catch
try {
const settings = await api.site.settings();
} catch (e) {
if (e instanceof Error && e.message === 'Failed to fetch site data') {
// render comments in a degraded state or hide with a message
}
} Prevention
- Ensure the comments-ui script tag has valid data-api-key and data-api-url attributes.
- Verify CORS is configured on the Ghost Content API for the embedding origin.
- Confirm the Content API key matches the site integration before deploying the embed.
When it happens
Trigger: The Content API settings request returns 4xx/5xx. The apiKey is missing or invalid (401/403), the apiUrl is misconfigured (404), CORS blocks the request, or the Ghost server is down. contentEndpointFor returns '' if apiUrl or apiKey is absent, and fetching '' resolves to a relative URL that typically fails — but the fetch to a blank URL usually yields ok=false on a document response.
Common situations: The comments-ui script is embedded without the correct data-api-key or data-api-url attributes. The Content API key belongs to a different site. The Ghost instance is behind a CDN that blocks the request. The site URL in the script does not match the API URL origin, triggering CORS rejection.
Related errors
- Failed to fetch comments
- Failed to fetch replies
- Failed to add comment
- Failed to edit comment
- Failed to read comment
AI-assisted analysis of TryGhost/Ghost@47d8b0e2ad (2026-08-13).
Data as JSON: /api/errors/c6f7280b0e930f46.
Report an issue: GitHub.