Revalidate ISR not working in VERCEL, does anyone have solution?
Answered
Lionhead posted this in #help-forum
LionheadOP
I have used this template https://github.com/nilooy/platforms to make a multi tenant platform. User can create and edit sites, but when the edit the sites, i call the
and it revalidate the path, it works fully locally if i do,
which is used for prod as far i know in vercel as well.
but deployed vercel and called revalidate, i can see the updated logs, so it gets called successfully, even i see the updated logs was in
this is the code for the static page
i tried purging cache from vercel, redeploying without cache, downgrading next.js version. it seems like locally i don't have any problems with isr with built version of the app but only on VERCEL.
next: 13.4.12
eslint-config-next: 13.4.12
react: 18.2.0
react-dom: 18.2.0
typescript: 5.0.4
Node: 18.10.0
npm: 8.19.2
Yarn: 1.22.19
pnpm: 8.1.1
await res.revalidate(`/_sites/${urlPath}`) and it revalidate the path, it works fully locally if i do,
next build && next start which is used for prod as far i know in vercel as well.
but deployed vercel and called revalidate, i can see the updated logs, so it gets called successfully, even i see the updated logs was in
getStaticProps but the page never gets updated, this is the code for the static page
export const getStaticProps: GetStaticProps<IndexProps, PathProps> = async (
ctx
) => {
const params = ctx.params;
if (!params) throw new Error("No path parameters found");
const { site } = params;
const pageData = await getPageDataBySite(site)
if (!pageData) return { notFound: true, revalidate: 10 };
return {
props: {
pageData
},
revalidate: 3600,
};
};i tried purging cache from vercel, redeploying without cache, downgrading next.js version. it seems like locally i don't have any problems with isr with built version of the app but only on VERCEL.
next: 13.4.12
eslint-config-next: 13.4.12
react: 18.2.0
react-dom: 18.2.0
typescript: 5.0.4
Node: 18.10.0
npm: 8.19.2
Yarn: 1.22.19
pnpm: 8.1.1
Answered by Lionhead
ok i found the fix , in vercel it's necessary to call the revalidate api with the subdomain/custom_domain hostname,
as example, if your site is
revalidate code: https://github.com/nilooy/platforms/blob/main/pages/api/revalidate.ts
as example, if your site is
example.com and the one you want to validate is sub.example.com then if you call this api https://example.com/api/revalidate to revalidate, it won't work, you need to send it on the subdomain as host, so -> https://sub.example.com/api/revalidate this does the work.revalidate code: https://github.com/nilooy/platforms/blob/main/pages/api/revalidate.ts
1 Reply
LionheadOP
ok i found the fix , in vercel it's necessary to call the revalidate api with the subdomain/custom_domain hostname,
as example, if your site is
revalidate code: https://github.com/nilooy/platforms/blob/main/pages/api/revalidate.ts
as example, if your site is
example.com and the one you want to validate is sub.example.com then if you call this api https://example.com/api/revalidate to revalidate, it won't work, you need to send it on the subdomain as host, so -> https://sub.example.com/api/revalidate this does the work.revalidate code: https://github.com/nilooy/platforms/blob/main/pages/api/revalidate.ts
Answer