RocketChat / EmbeddedChat

An easy to use full-stack component (ReactJS) embedding Rocket.Chat into your webapp
https://rocketchat.github.io/EmbeddedChat/docs
115 stars 236 forks source link

Set up RC host url as environment variable in react storybook #265

Closed abhinavkrin closed 1 year ago

abhinavkrin commented 1 year ago

Description

The RocketChat Host URL is currently hardcoded as http://localhost:3000 in the React Storybook configuration. However, it is essential to provide flexibility and configurability by allowing users to set the host URL via environment variables. This change will make it easier for users to adapt the configuration to their specific needs.

Proposed Solution

We should modify the React Storybook configuration to read the RocketChat Host URL from an environment variable. By default, if the environment variable is not set, it should fallback to http://localhost:3000. So that if developers want to use HTTP://localhost:5000 as host url, then the storybook could be started using:

RC_HOST=http://localhost:5000 yarn storybook

or by setting up a .env file (it should be added to gitignore).

Steps to Implement

  1. Update the React Storybook configuration to use an environment variable for the RocketChat Host URL.
  2. Provide clear documentation on how users can set the environment variable.
  3. Ensure that when the environment variable is not set, it defaults to http://localhost:3000.
  4. Change all the hardcoded host URLs to use environment variable.
  5. Update readme accordingly.

Expected Behavior

Users should be able to easily configure the RocketChat Host URL for React Storybook by setting an environment variable. When no environment variable is set, it should default to http://localhost:3000.

tanu-chahal commented 1 year ago

Hey @abhinavkrin, do we have to add dotenv for this in react folder?

I want to work on this issue. Can you please assign it to me?

abhinavkrin commented 1 year ago

Hey, @tanu-chahal Thank you, I have assigned this issue to you. You can refer to https://storybook.js.org/docs/react/configure/environment-variables/ for working.

tanu-chahal commented 1 year ago

Hey @abhinavkrin, thanks for the resources & assigning the issue to me, I have a query do we need to change the host in the stories of the chat component only? Or do we need to do it everywhere in api, auth, and every directory wherever localhost:3000 is hardcoded?

abhinavkrin commented 1 year ago

@tanu-chahal A better option would be to replace every instance of hard coded host url.