- Issue created by @akalata
- πΊπΈUnited States markie Albuquerque, NM
I can confirm that '@lullabot/storybook-drupal-addon', is the thing causing this. You just need to remove it from your .storybook/main.js and restart storybook. Now the issue with this is all your stories.yml files will bork.
- Status changed to Fixed
about 1 year ago 9:38pm 6 February 2024 - e0ipso Can Picafort
I agree with @markie. You should uninstall the addon.
- π΅πͺPeru diegoe Lima, PerΓΊ
Just for posterity, I did some digging and this is the reason why things break:
See the routing expectations for each drupal-side module:
# https://git.drupalcode.org/project/cl_server/-/blob/2.x/cl_server.routing.yml cl_server.render: path: "/_cl_server" # https://git.drupalcode.org/project/storybook/-/blob/1.x/storybook.routing.yml storybook.render_story: path: /storybook/stories/render/{hash}
Because `drupal/storybook` generates stories with a full `parameters.server.url` value, the `@lullabot/storybook-drupal-addon` addon will append `/_cl_server`, a _last part of the URL path_, to said URL:
// web/themes/custom/my_theme/templates/colors.stories.json { "title": "Color examples", "parameters": { "server": { "url": "https://my-site.ddev.site/storybook/stories/render" } }, // https://github.com/Lullabot/storybook-drupal-addon/blob/main/src/fetchStoryHtml.ts#L46 const fetchUrl = new URL(`${url}/_cl_server`); ``` So, we end up with a URL that goes straight to `drupal/storybook`'s routing (despite the suspicious `/_cl_server` path): <code> # This is what `drupal/storybook` understands, a full base64 encoded JSON /storybook/stories/render/aLongBase64Hash= # This is what `drupal/cl_server` understands, a simple query string: /_cl_server?_storyFileName=.%2Fweb%2Fthemes%2Fcustom%2Fmy_theme%2Ftemplates%2Fcolors.stories.json&_drupalTheme=my_theme # This is what is getting requested: /storybook/stories/render/_cl_server?_storyFileName=.%2Fweb%2Fthemes%2Fcustom%2Fmy_theme%2Ftemplates%2Fcolors.stories.json&_drupalTheme=my_theme
Since `drupal/storybook` is trying to `base64_decode()` the last part of the URL path, it tries to decode `"_cl_server"`, which doesn't work:
https://github.com/e0ipso/twig-storybook/blob/main/src/Service/StoryRend...Perhaps it would be possible to have `twig-storybook` throw a more specific error if what fails is the `base64_decode()` call, like in this scenario. So that users know what "tampering with the URL" actually means in that case (?). Would you be interested in a ticket+patch for that @e0ipso?
Overall I agree that these are simply incompatible, but if anyone cared to have them both at the same time for whatever reason, then the fix is to edit your generated `.stories.json` files to point to a URL that makes sense for `@lullabot/storybook-drupal-addon`.
Automatically closed - issue fixed for 2 weeks with no activity.