darkwire / darkwire.io

End-to-end encrypted instant web chat

Home Page:https://darkwire.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Store configuration is not loaded

jrmi opened this issue · comments

Due to the way import works, dotenv file is loaded after store file. The store initialisation should be lazy.

Hmm I haven't tested this locally but that shouldn't be the case. How can I reproduce this?

Try to use the memory backend. Since the store initialisation is in another file, it's broken and it always take the default values as process.env is not populated with .env file.

You can also log process.env in server/store/index.js file.

in my understanding, the module imports are done and then the code is executed. The problem with the require(dotenv).config() line is that the .config() is executed after the all other import are done so the store/index.js is loaded before the process.env population, which then initialized without the variables in the .env file.