mswjs / msw-storybook-addon

Mock API requests in Storybook with Mock Service Worker.
https://msw-sb.vercel.app
MIT License
408 stars 39 forks source link

fix: update the worker script #70

Closed kettanaito closed 2 years ago

kettanaito commented 2 years ago

Attempts to resolve the following runtime error that, supposedly, happens when fetching the worker script:

A bad HTTP response code (404) was received when fetching the script.
vercel[bot] commented 2 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/mswjs/msw-storybook-addon/4BsS5TeT29SHLmBuoKptPpakW6gp
✅ Preview: https://msw-storybook-addon-git-fix-worker-script-404-mswjs.vercel.app

kettanaito commented 2 years ago

To start, I'm updating the worker script to be aligned with the latest installed msw. That shouldn't affect how the script is fetched in any way, though.

kettanaito commented 2 years ago

The worker script is never present in the storybook-static dir, which is the server app's root. We need to respect NextJS's public directory during the build.

kettanaito commented 2 years ago

The build-storybook command we were using was referring to the build-storybook binary. Since we called it without any options in the root-level yarn build, it never copied the Next's public dir to its static dir.

Fixing this to refer to our own custom storybook-build command.