Describe your question/issue in detail
Hello Prismic Team!
I use a Prismic API link to retrieve content from our Prismic repository (things like articles, information about companies, etc). I then serve that content via our client using Next.JS.
I have noticed that some of my API information is up-to-date, while the information in other places is stale info -- for instance, one section of the website is showing the newest information on a company, whereas a different website is showing old information for that company (e.g. image links, title, etc).
I have checked that I am using up-to-date CDN links ({repo}.cdn.prismic.io/api/v2) and I am quite sure I do not have two versions of the same documents. Can you advise on what could be causing this?
Impacted feature
API CDN
What steps have you taken to resolve this issue already?
Update document
Unpublish and republish document
local debugging
Errors
None
Your Role
Sole Developer
Hosting provider
Vercel
Package.json file
{
"name": "thom",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"slicemachine": "start-slicemachine"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.2.1",
"@fortawesome/free-brands-svg-icons": "^6.3.0",
"@fortawesome/free-solid-svg-icons": "^6.2.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@next/font": "13.1.0",
"@piwikpro/next-piwik-pro": "^1.0.4",
"@piwikpro/react-piwik-pro": "^1.1.1",
"@prismicio/client": "^7.0.0",
"@prismicio/next": "^1.5.0",
"@prismicio/react": "^2.7.4",
"@prismicio/slice-simulator-react": "^0.2.3",
"eslint": "8.30.0",
"eslint-config-next": "13.1.0",
"lodash": "^4.17.21",
"next": "13.4.5",
"next-transpile-modules": "^10.0.0",
"prismic-javascript": "^3.0.2",
"pure-react-carousel": "^1.30.1",
"react": "18.2.0",
"react-countup": "^6.4.1",
"react-dom": "18.2.0",
"react-fast-marquee": "^1.3.5",
"react-icons": "^4.7.1",
"react-marquee-slider": "^1.1.5",
"react-responsive": "^9.0.2",
"react-transition-group": "^4.4.5",
"styled-components": "^5.3.9"
},
"devDependencies": {
"@prismicio/types": "^0.2.7",
"slice-machine-ui": "^0.7.1"
}
}
Steps to reproduce
Simply fetching data and returning via a CreateClient endpoint seems to be causing the issue. The section with outdated info uses this:
const endpoint = "https://thomnext.cdn.prismic.io/api/v2";
const token = process.env.TOKEN;
const client = prismic.createClient(endpoint, { accessToken: token });
Whereas the section with updated info uses this context instead:
// Fetch companies
const companyResponse = await client.getByType('company', { pageSize: 100 });
const companies = companyResponse.results;
// Fetch a specific page by UID
const page = await client.getByUID('pageh', params.uid);
return {
props: {
page,
articles,
team,
companies
}
};
}
export async function getStaticPaths() {
const client = createClient();
const pages = await client.getByType('pageh');
return {
paths: pages.results.map(page => {
return { params: { uid: page.uid } }
}),
fallback: false
};
}
const Page = ({ page, articles, team, companies }) => {
return (
<SliceZone
slices={page.data.slices}
components={components}
context={{ "articles": articles, "team": team, "companies": companies }}
/>
);
}