Join the Webstudio community

Updated 8 months ago

Notion Images: Links expire

At a glance

The community member is using Notion as a source for images and text, but they noticed that the links retrieved by the Notion API expire after some hours, causing the images to no longer load. The community members discuss this issue and provide some insights:

- The issue seems to be related to the Notion API, and the community members suggest checking the Notion documentation for more information.

- The community members discuss the Notion API documentation, which states that the public URLs for files are updated each time a database or page is queried, and that these URLs should not be statically referenced.

- The community members suggest that the issue may be related to the way the community member is accessing the Notion data, and they provide some suggestions on how to properly format the image URLs.

- One community member suggests that the "Optimize Image" setting in Notion may be causing the issue, and turning it off solves the problem. However, another community member later suggests that the issue has been resolved on Notion's side, and the "Optimize Image" setting can be turned back on.

There is no explicitly marked answer in the comments, but the community members provide several suggestions and insights that help address the issue.

Useful resources
Hi,
I am using Notion as a source for images and text. Works super well, but i noticed after some hours (I think 48) the links the are retrieved by the notion API do expire and the images cannot be loaded anymore.

Is there any way to prevent this?
2
O
I
s
22 comments
this must have to do with notion api, is there info about it in their docs?
You mean you are copypasting notion image src?
As accessing notion data through API should not have issues like above
https://developers.notion.com/docs/working-with-files-and-media#:~:text=Retrieving%20files%20and%20media%20via%20the%20Notion%20API&text=The%20public%20URLs%20are%20updated,shouldn't%20be%20statically%20referenced.

thats the information i've found there. I think im making a mistake, because these links should normally renew but for me they did not.

In webstudio it looks like this for me:

{Name of Variable}.properties.BlogBild.files[0].file.url
The Url looks to be correct aswell but returns a 403 error when visited
Attachment
Bildschirmfoto_2024-06-27_um_14.16.47.png
documentation says: "Each time a database or page is queried, a new public URL is generated for all files hosted by Notion."
unfortunately they don't allow keeping a cache
it seems their api is not meant to be used as a headless api at all, its meant to be used for import/export
Yeah i've found so. When I inspect the data retrieved the Image URL is acutally the correct one, with the new experiy date. But inside my Collection Item, there is still the first one.
See how react notion makes images URLs for notion
@Ivan Starkov in simple terms, you think adding all those values to the query allows to get image accesson every call?
Few days ago I saw format above on notion pages, and it works everywhere
every image src must be converted using algorithm above
You need to know block.value.parent_table and block.value.id
Is optimize image enabled @stoesselleon that nows causes a problem
Yeah i had it turned on. Turning it off actually solved the issue @John Siciliano! Thank you for the hint
for awareness, i updated the notion doc, image component doc with optimize desc, and notion template
@stoesselleon Sike, try turning it back on. We were able to do something on our side that fixes it
great to hear! it works fine for now πŸ‘Œ
Off topic here – but I did not see a more matching place ...

Notion has recently launched an update to their shared pages. They now offer an elementary website builder, which lets you connect custom domains. To use domains you already own, you need to pay 8 or 10 dollars a month, depending on your Notion licence. https://www.notion.so/help/notion-sites-availability-and-pricing

Their builder does a lot less than apps like Super.
Add a reply
Sign up and join the conversation on Discord