tjtanjin / react-chatbotify

A modern React library for creating a flexible and extensible chatbot.
https://react-chatbotify.tjtanjin.com/
MIT License
103 stars 49 forks source link

[Feat] Implement dotenv to manage environment variables #48

Closed Andres2D closed 2 months ago

Andres2D commented 2 months ago

Description The project should have at least one .env file to store multiple environment variables used in the codebase.

The solution Fortunately, as this projects uses vite, we can take advantage to the fact that vite uses dotenv by default. It just requires a simple configuration to start using environment variables. Check the documentation

Alternatives There's really no better way to handle the issue. Other options are to use secret management platforms like Infiscal. However, as vite is already using dotenv by default, we should go ahead with dot env.

Additional context Having an environment variable configuration is a core functionality for any project. I may be a little troublesome at first due to the fact that every developer must create a new non-tracked file for their cloned repository. However, like I said before, this is a core functionality.

An example This is a basic example of the implementation of a dotenv configuration.

In file BotOptionsService.tsx Screenshot 2024-05-02 at 2 52 11 PM

The idea is to replace the static variable for the CDN link and have the option to get it from the .env file.

Screenshot 2024-05-02 at 2 52 43 PM

Then, in the .env file, we will be able to switch between a production environment link and a local development link.

tjtanjin commented 2 months ago

Resolved in #49