const { URL } = process.env;
alert(URL);
export const API_URL = URL;
my consants File. Here i am using backend url from.env File. But i am getting undefined when alert.
URL=http://statrix.ru
Here is my.env File.
Please let me know whats wrong i am doing
If you are using create-react-app to initialize your project so I think you should put prefix REACT_APP
before your environment variable.
In this case, that should be
REACT_APP_URL=http://statrix.ru
and to get this variable in your javascript that should be
const { REACT_APP_URL } = process.env;
For more your information, please read official document at here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.