P粉3331862852023-09-04 08:17:05
For all custom environment variables in the application created through create-react-app, we need to use REACT_APP_ prefix in the environment variable name, this is a requirement, if we do not follow the convention, the variable will not be accessible, That's it, just like VITE you need to combine VITE_.. or Nextjs with NEXT_PUBLIC... (Client components only)
Also, remember that all values are accessible on the client (browser). You should not use it for any data/credentials that your users should not have access to in the browser and for any super secret API keys.
For maximum security, this should be used on the backend, and no prefix is required on the backend.
For more details you can check out the old documentation (again) on CRA https://create-react-app.dev/docs/adding-Custom environment variables