Skip to content

Using getStaticProps for fetching images hosted on Notion? #8

Closed

Description

@spencerwooo

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!

Activity

  1. jinalex commented on Jun 29, 2022

    @jinalex

    Also interested in this! @spencerwooo have you found a solution by any chance?

  2. sorcererxw commented on Jul 16, 2022

    @sorcererxw

    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.

  3. jordymeow commented on Sep 15, 2022

    @jordymeow

    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?

  4. FarazPatankar commented on Nov 15, 2022

    @FarazPatankar
    Collaborator

    Hey y'all, this is what we're doing for now: #18

  5. ImBIOS commented on Feb 9, 2023

    @ImBIOS

    @FarazPatankar I think this issue was resolved 🥳

  6. christiankaindl commented on Feb 9, 2023

    @christiankaindl

    Hey y'all, this is what we're doing for now: #18

    This solution is very elegant and works great! Thanks 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions