A
A
albertalexandrov2018-12-29 08:27:20
Node.js
albertalexandrov, 2018-12-29 08:27:20

Why doesn't dotenv read variables from .env?

Hello!)
I want to read environment variables in a react application from a .env. For this I use the dotenv library .
I created using the create-react-appapp. The default structure. All I have added is the import dotenvand in the application Appoutput to the console environment variables:
5c2705115498d331933643.png
To the .envfollowing:

URL=vk.com

In response I get undefined. Everything seems to be on the dock. What could be the omission?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladlen Hellsite, 2018-12-30
@albertalexandrov

The dot-env module is server-side, you cannot use it on the client. At most, you can parse its values ​​​​in JSON and throw it into the assembly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question