-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Opening storybook-static/index.html in browser does not work anymore in v7 #21978
Comments
Same issue happening for me, its quite blocking imo, since we can't build and deploy our storybooks. |
Hi, the v7 docs recommend using a server to view your build output. Just run |
@mert-duzgun thanks for pointing this out 👍 . Was wondering why our deployed builds stopped working after upgrading to SB v7 since everything seemed to be ok with builds. |
@mert-duzgun using a server is not an (easy) option for us. So far, we have simply built the static stroybook in Jenkins and served it as Jenkins artifact. If we really need a full web server for this, we would need to set up quite a bit of additional infrastructure (for each storybook—yes, we have multiple...). Of course it's possible, but we really appreciate the simplicity of the previous solution. |
@shilman happy user of v7 here :), just wondering what is the reason for this "change" in build output, I assume storybook build process (and tooling) got much more complex, and can't be served as before in v6? |
+1 to the list. This makes our lifes significantly harder. For me the problem is that storybook is available here: https://chair-flight-cxdu0ds6v-puposdc-s-team.vercel.app/storybook` and its trying to fetch from the wrong directory. Ie.e: instead of |
@FlorianChristie the issue is that file:// protocol doesn't support import/export in order to serve the build locally, one of the way just install VSCode extension calling LiveServer (Five Server) then by pressing 1 button you will start to serve your opened folder in this way you will not have any extra scripts in your package.json |
My understanding, based on convo with the other maintainers, is that we are using modern ESM now and the browser CORS rules are more restrictive for browsing file URLs with ESM. @ndelangen did I get that right? |
FWIW, I got around my particular issue by using next js redirect: module.exports = withNx(
withBundleAnalyzer(
withMDX({
async rewrites() {
return [
"assets",
"sb-addons",
"sb-common-assets",
"sb-manager",
"sb-preview",
"index.json",
"iframe.html",
"project.json",
"stories.json",
].map((source) => ({
source: `/${source}/:path*`,
destination: `/storybook/${source}/:path*`,
}));
},
})
)
); This might become a problem if we ever decide to have more than one SB... but realisticly we won't so I think we are good for now :D (Also, PS... storybook 7 is just great. I have always had one pickle or another with SB... but the new format really makes the whole experience so smooth) |
@shilman browsers not supporting ESM natively when on the I'm guessing the issue can be closed with "won't fix" if it's purely about the fact this protocol doesn't work anymore.
... will do it. If this issue is about something else as well too, perhaps it should stay open? |
Sorry, I made that a bit unclear in my initial message. For me personally, there is no problem with storybook v7 for local development. But since we share the static pages with other people (e.g. UI designers) that mostly don't have node installed we relied on just archiving the static story book pages e.g. in Jenkins. This is basically the problem that @ghost91- and @PupoSDC described. |
It's a breaking change when migrating from v6, so this should be mentioned in the migrating docs. |
#20157 (comment) <- solved it for us. we're serving from s3 with nginx |
I believe @shilman added it to the migration guide some time ago. |
Yup, it's there https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#dropped-support-for-file-urls We also find a workaround meanwhile by adapting our Jenkins CSP. I will close this issue, since it is mentioned in the official migration for v7 and thus the new wanted behavior. 🙂 Thanks for the discussion and all the hints and comments. ❤️ |
Describe the bug
When trying to open the output generated from
storybook build
(storybook-static/index.html) in Chromium (or Chrome or Firefox) only a blank page is shown. The console errors suggest that this is a problem with the CORS policy:Access to script at 'file:///home/username/test-sb/storybook-static/sb-manager/runtime.mjs' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.
When starting Chromium with disabled web security (
chromium --disable-web-security --user-data-dir="[storybook-test]"
) the storybook can be opened.Is there any way to get this running again without having to start Chromium in this mode? We did rely on this as we do not deploy our storybook anywhere but rather just archive the static files.
To Reproduce
mkdir test-sb && cd test-sb
npm init
npm install react react-dom
npx sb init
npm run build-storybook
Open
/home/username/test-sb/storybook-static/index.html
in ChromiumSystem
Additional context
No response
The text was updated successfully, but these errors were encountered: