Lullabot / storybook-drupal-addon

Storybook addon to facilitate integrating Storybook with Drupal projects.
MIT License
39 stars 7 forks source link

Error with Storybook making a request to Drupal #45

Open fogpuddle opened 7 months ago

fogpuddle commented 7 months ago

I'm following the walkthrough at https://git.drupalcode.org/project/cl_server/-/blob/2.x/docs/storybook.md, but am running into an error with Storybook connecting with Drupal using this addon. I'm not sure if I'm missing some setting in the walthrough, but I went through this many times getting this error. This is what I'm seeing using DDEV to set this up.

Screenshot 2023-10-27 at 10 37 53 AM

It could be an error with CL Server, but I made sure then endpoint was accessible to anonymous users in the Drupal settings.

There is a part in the walkthrough where it says this:

"Storybook will start in http://localhost:6006/ and you will see a black and red screen with an error. This is because you need to set the Components config in Drupal."

As you can see in the screenshot, I am seeing a black and red screen with an error in storybook, but I'm not sure where to go to set the Components config in Drupal nor what to set in the config if that is indeed the problem.

fogpuddle commented 6 months ago

I'm just following up. Is anybody else seeing this error or is there a step I'm missing that will resolve the Storybook issue mentioned above.

e0ipso commented 6 months ago

@fogpuddle what are you seeing in the JS console?

fogpuddle commented 6 months ago

@e0ipso This is what I'm seeing in the console:

Screenshot 2023-11-27 at 11 32 49 AM

When I look at the cl_server path in the network tab. I see the 404 status code for the request URL of https://storybook-sdc.ddev.site:6006/_cl_server?_storyFileName=.%2Fweb%2Fthemes%2Fcustom%2Fstorybook_sdc%2Fcomponents%2Fmy-banner--tall%2Fmy-banner--tall.stories.yml&_drupalTheme=undefined&_params=eyJoZWFkaW5nIjoiSm9pbiB1cyBhdCBUaGUgQ29uZmVyZW5jZSIsImltYWdlIjoiaHR0cHM6Ly9waWNzdW0ucGhvdG9zL3NlZWQvYWZmc2UzLzEyMDAvOTUwIiwiY3RhVGV4dCI6IlJlZ2lzdGVyIiwiY3RhSHJlZiI6Imh0dHBzOi8vd3d3LmV4YW1wbGUub3JnIn0%3D

Within the above URL, I notice the drupalTheme parameter as being undefined. Could it be related to how I set up the custom theme in preview.js?

globals: { drupalTheme: "storybooksdc", supportedDrupalThemes: { storybooksdc: {title: "storybook_sdc"}, olivero: { title: "Olivero" }, claro: { title: "Claro" }, }, },

CL Server is enabled in Drupal and the permission for CL Server Endpoint is set to anonymous.

e0ipso commented 6 months ago

Is the module/theme that contains the components enabled?

Do click on that link to see if it paints the component in Drupal.

fogpuddle commented 6 months ago

@e0ipso The theme that contains the components was enabled. When clicked the link, I get "Cannot GET /_cl_server."

I'm wondering if it's something in the DDEV configuration or development.services.yml file that's preventing the Drupal connection. I'll take another look, but I'm not too knowledgable about those settings.

fogpuddle commented 4 months ago

@e0ipso Coming back to this, I was able to resolve the 404 issue after many reinstalls. I believe it had to do with Drupal configurations and/or caching issues, but I couldn't pinpoint.