Skip to content
Discussion options

You must be logged in to vote

When deploying React apps, this is a well-known and frequent problem! In order to avoid unintentionally exposing sensitive server-side variables, the issue is with the way Create React App (CRA) manages environment variables during the build process. The explanation and solution are as follows:

1.The Reason: The Prefix REACT_APP_
Environment variables are only automatically included in the final client-side bundle by Create React App (and many other well-known React build tools, such as Vite and Next.js) if they are prefixed with REACT_APP_. In order to avoid being bundled into the public JavaScript files, any variable that does not have this prefix is handled as a server-side/private var…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Litis-Trion250
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Ask and answer questions about GitHub features and usage Programming Help Discussions around programming languages, open source and software development
2 participants