You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Using getStaticProps for fetching images hosted on Notion? #8
Hi there, apologies for posting this random question here, but I was curious about how you overcame the issue for rendering images hosted on Notion and also using next/image for optimisation? (As I myself ran into a similar problem when switching to Notion's public API for blog hosting.)
The problem I ran into was that Notion's public API responds with URLs of images hosted on Notion that are short-lived - they would expire after a certain amount of time (seems to be 1 hour).
This means that there would exist a possible time span where ISR is still revalidating but the images have already expired, resulting in broken images for visitors accessing the site during this particular time - and I've personally ran into this for a couple of times over on my site.
It also implies that next/image would have to optimise a whole lot of images with different URLs while they are still the same one in reality - leading to an email from Vercel telling me that I have gone over my limit for image optimisation.
It was not until Next.js 12.1 (released literally yesterday) before we could on-demand ISR with webhooks (On-demand Incremental Static Regeneration). So I was curious about if you had some solutions to this issue without on-demand ISR?
My workaround was that I had to resort to using getServerSideProps without image optimisation for serving fresh images. But I skimmed through your repo and found that you were still using getStaticProps, and hence this question ;)
And thanks for the awesome railway.app, I'm loving it!
I also use Notion as my blog CMS. I find that the images sometimes don't load because they are expried. Therefore, I use a cronjob to regenerate the SSG pages.
The cronjob will load the sitexml and request to revalidate each path, and finally, request each page to make sure the generation is complete.
I am also interested in an elegant solution; I am not sure forcing the SSG pages to regenerate is good, but maybe by finding a way for NextJS to consider an image is the same as previously without the need to optimize it?
Activity
jinalex commentedon Jun 29, 2022
Also interested in this! @spencerwooo have you found a solution by any chance?
sorcererxw commentedon Jul 16, 2022
I also use Notion as my blog CMS. I find that the images sometimes don't load because they are expried. Therefore, I use a cronjob to regenerate the SSG pages.
The cronjob will load the sitexml and request to revalidate each path, and finally, request each page to make sure the generation is complete.
It works well currently.
jordymeow commentedon Sep 15, 2022
I am also interested in an elegant solution; I am not sure forcing the SSG pages to regenerate is good, but maybe by finding a way for NextJS to consider an image is the same as previously without the need to optimize it?
FarazPatankar commentedon Nov 15, 2022
Hey y'all, this is what we're doing for now: #18
ImBIOS commentedon Feb 9, 2023
@FarazPatankar I think this issue was resolved 🥳
christiankaindl commentedon Feb 9, 2023
This solution is very elegant and works great! Thanks 🙏