my question if we host react app on github pages and put apikey in .env file it's going to work or not or any other better method of hiding api key.
Asked
Active
Viewed 1,110 times
0
-
check this out https://stackoverflow.com/questions/48699820/how-do-i-hide-api-key-in-create-react-app – Meet Majevadiya Jul 06 '22 at 14:13
1 Answers
1
Using a .env file would not work, as its purpose is to not be included in the version controlled repository. Instead, I would recommend to use a .env file while developing locally and then host it in Vercel or Netlify, which both support environment variables. With that said, you still shouldn't really be accessing APIs from your frontend, especially with API keys, and should instead be accessing them from the backend.

Kyle Kingsberry
- 83
- 6