Skip to content
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

Environment variables in HTML files not working anymore #14438

Closed
danielkoch opened this issue Apr 1, 2021 · 3 comments
Closed

Environment variables in HTML files not working anymore #14438

danielkoch opened this issue Apr 1, 2021 · 3 comments

Comments

@danielkoch
Copy link

Describe the bug
I upgraded from from 6.1.21 to 6.2.1 and it seems that Environment variables (https://storybook.js.org/docs/react/configure/environment-variables) not working anymore in HTML files. I used one before in preview-head.html

To Reproduce
Add environment variable into preview-head.html. Example: %BRAND%. Start Storybook BRAND=value start-storybook

Expected behavior
Environment variables should be replaced with given value.

Screenshots
sb-environment-variable

System

Environment Info:
  System:
    OS: macOS 11.2.3
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
  Binaries:
    Node: 14.16.0 - ~/.nvs/node/14.16.0/x64/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.14.11 - ~/.nvs/node/14.16.0/x64/bin/npm
  Browsers:
    Chrome: 89.0.4389.90
    Edge: 89.0.774.63
    Safari: 14.0.3
  npmPackages:
    @storybook/addons: 6.2.1 => 6.2.1 
    @storybook/react: 6.2.1 => 6.2.1 
    @storybook/theming: 6.2.1 => 6.2.1 
@shilman
Copy link
Member

shilman commented Apr 1, 2021

We think this is a bug in 6.1. We explicitly filter out environment variables that don't start with STORYBOOK_ for security purposes. If you put the variable in a .env file, then you don't need to prefix it.

Closing this for now. Please let me know if you have any issues!

@danielkoch
Copy link
Author

@shilman: Means the bug is that it worked till 6.1?
Using .env file is not really an option because I need to run the script multiple times with different environment values.

@shilman
Copy link
Member

shilman commented Apr 1, 2021

@danielkoch yes, I'm surprised it worked at all since the variable is not prefixed with STORYBOOK_

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants