build-storybook to subfolder results in 404 from iframe.html
See original GitHub issueFailed to load resource: the server responded with a status of 404
/assets/vendor.[hash].js /assets/iframe.[hash].js /assets/iframe.[hash].css
To reproduce:
npx build-storybook --output-dir build/docs
npx serve@latest build
Browse to http://localhost:3000/docs/
Cause:
in the generated build/docs/iframe.html these assets are loaded via absolute urls: src="/assets/...
Possible fix:.
Generate relative urls: src="assets/... (no leading slash)
Workaround: Running a post build script:
const fs = require('fs');
const filename = 'build/docs/iframe.html';
let html = fs.readFileSync(filename, "utf8");
html = html.replaceAll('"/assets/', '"assets/');
fs.writeFileSync(filename, html);
// repeat for other files that use /assets/ urls.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:19 (11 by maintainers)
Top Results From Across the Web
build-storybook to subfolder results in 404 from iframe.html - Issues ...
build-storybook to subfolder results in 404 from iframe.html. Failed to load resource: the server responded with a status of 404. /assets/vendor.
Read more >Build Storybook iframe.html Failed to load resource #11694
When build storybook is executed, output is executed or distributed. However, it failed to load resoure despite the bundle file in iframe.html.
Read more >Storybook IFrame 404 - Simon Online
In this case we had a project called Agent%20Portal on disk. Renaming it to just AgentPortal fixed up storybook right away.
Read more >iframe.html no longer built with --preview-url #14591 - Issuehunt
Initially, we built the static files with build-storybook -o public/view-components/stories . But we had an issue that when accessing localhost:4000/view- ...
Read more >404 page when trying to access a /media subdirectory file in ...
I try to load a pdf file into an iframe using JavaScript in a magento page: My pdf files are stored in /media/subdirectory....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks!
works in both
start-storybook&build-storybook, shouldbase: ''be the new default for storybook-builder-vite?Is this helpful? https://github.com/eirslett/storybook-builder-vite/issues/96#issuecomment-1016548429
Essentially, I think you need to set the
basefor vite, so it knows that you have a nested directory.