Skip to content

Fix: Handle storybook V8 fetch call#547

Open
bassem-i wants to merge 2 commits into
oblador:masterfrom
bassem-i:fix/handle-stories-fetch-storybook-v8
Open

Fix: Handle storybook V8 fetch call#547
bassem-i wants to merge 2 commits into
oblador:masterfrom
bassem-i:fix/handle-stories-fetch-storybook-v8

Conversation

@bassem-i
Copy link
Copy Markdown

@bassem-i bassem-i commented Jul 30, 2025

We are currently migrating our Storybook version from 7 to 8. We've noticed that:

A fetch call in Storybook V8 breaks loki's aws-lambda-renderer.

Storybook V8 initialization calls getStoryIndexFromServer function which tries to load a file called index.json (A json with all the stories loaded in the storybook build) using fetch. This breaks Loki's aws-lambda-renderer because it depends on file-based file://TMP_FOLDER/iframe.html?id=STORY_ID access. (File-based access doesn't support fetch).

This PR fixes the failed to fetch error by handling the fetch call without actually fetching.

  1. Loki's aws-lambda-renderer script (running on lambda) does a readFileSync to load the content of index.json file.
  2. Loki's aws-lambda-renderer script injects a script into the chrome tab running Storybook to overwrite the fetch function implementation as follows:
  • If fetch is called with index.json, it returns the stories list.
  • If fetch is called with any other input, it invokes the original fetch.

@bassem-i
Copy link
Copy Markdown
Author

I've found another approach that keeps the file-based url access: #546

@bassem-i bassem-i marked this pull request as ready for review July 31, 2025 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant