Home > database >  Where the .env keys get stored after the nom build command in react?
Where the .env keys get stored after the nom build command in react?

Time:12-05

Hello guys I build a react application using Django as the backend and having many keys at.env file. Now when I build the react app with the ‘npm run build’ command it builds the index file with CSS in the build folder. But where it stores all the keys of the .env file which were used in some components. Or its gets build with all the components

CodePudding user response:

On a client-rendered application (like a standard React app), the build process will embed the actual environment variable values in your bundled code, making it available when serving the build to a hosting server.

Reference from the "Create React App" documentation

WARNING: Do not store any secrets (such as private API keys) in your React app!

Environment variables are embedded into the build, meaning anyone can view them by inspecting your app's files.

CodePudding user response:

when you run npm run build The environment variables are embedded and you can read them at runtime. by loading HTML into memory on the server and replacing placeholders in runtime . check docs for more information

  • Related