I am trying to deploy a react application in a shared hosting, but I am wondering how to deal with the env variables I stored in.env file. Such as api url for axios call etc. Should i create a.env file after building the react application?
Yes, you need to create .env file after create a react app and
You need to write .env with the REACT_APP prefix like
REACT_APP_BASEURL = 'url'
You can access them this code
process.env.REACT_APP_BASEURL
Hope so it will help you.
you can access them in this way :
process.env.BACKEND_BASEURL
in your .env :
BACKEND_BASEURL=http://example.com
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.