Stories not working, even after JSON file generating

Created on 24 June 2024, 3 months ago
Updated 19 September 2024, 10 days ago

I have a Drupal 10 project with Lando.

I have added side-by-side component in my project following this example, but it is not working, there is no Side By Side story.

I run npm run storybook not lando npm run storybook

Code of generated JSON file

{
  "title": "Side By Side",
  "parameters": {
    "server": {
      "url": "http://default/storybook/stories/render"
    }
  },
  "stories": [
    {
      "name": "1. Default",
      "args": {
        "heading_level": 3,
        "image_alt": "Alternative text for a random image."
      },
      "parameters": {
        "server": {
          "id": "eyJwYXRoIjoidGhlbWVzXC9jdXN0b21cL3RhaWx3aW5kX3RoZW1lXC9jb21wb25lbnRzXC9zaWRlLWJ5LXNpZGVcL3NpZGUtYnktc2lkZS5zdG9yaWVzLnR3aWciLCJpZCI6ImRlZmF1bHQifQ%3D%3D"
        }
      }
    }
  ]
}

Screenshot of StoryBook directories

Screenshot of component directory

Screenshot of my StoryBook page

Screenshot of the lando.yml file

Screenshot of result 'npm run storybook' command

Screenshot of result 'lando npm run storybook' command

💬 Support request
Status

Closed: cannot reproduce

Version

1.0

Component

Storybook

Created by

🇦🇲Armenia Sergey Gabrielyan Yerevan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Sergey Gabrielyan
  • 🇪🇸Spain idiaz.roncero Madrid

    Your URL starts with http://default/, which might be the problem - it looks like it won't be accessible by Storybook.

    This might be related to the way the `drush storybook:generate-stories` is run. Are you running it from inside a container (docker, ddev, lando)? I'm facing this same issue: the URL generated does include a "default" part instead of the site URL.

  • Status changed to Closed: cannot reproduce 19 days ago
  • 🇨🇦Canada tanner.svg

    I was running in the same issue where after following the "Drupal & Storybook in 5 Minutes" video and generating the .stories.json files using drush storybook:generate-stories.

    I was met with the following error:

    Upon reviewing my button.stories.json file I observed the same server URL as shown in this issue's screenshot.

    "parameters": {
        "server": {
          "url": "http://default/storybook/stories/render"
        }
      },
    

    Note: I am NOT using a container (docker, ddev, lando) for my local environment (my development environment is running directly on my local machine).

    ----

    In my case the solution was to add:

    export DRUSH_OPTIONS_URI="http://my-local-site-url.localhost"
    

    to my ~/.bash-profile, delete the already generated .stories.json files, then re-run drush storybook:generate-stories. After that the generated JSON was corrected to:

    "parameters": {
        "server": {
          "url": "http://my-local-site-url.localhost/storybook/stories/render"
        }
      },
    

    and my stories began working as expected.

    ----

    Additional note: I did reference a .lando.yml file to come to the conclusion as to what I needed. I've never needed this environment variable set to work on a Drupal site prior to using this module so maybe something could be added to this module to account for that? Or perhaps document how to work around this scenario if not using a container. Here's the lando config i referenced where this environment variable is set.

    tooling:
      drush:
        service: appserver
        env:
          DRUSH_OPTIONS_URI: "https://my-local-site-url.lndo.site/"
    
Production build 0.71.5 2024