No custom variable available without REACT_APP_ prefix
michalpaukert opened this issue · comments
Michal Paukert commented
cross-env
version: 6.0.3node
version: 12.13.0npm
(oryarn
) version: 6.13.1
What you did:
"start-cz": "cross-env LANG=cz react-scripts start"
What happened:
console.log(process.env);
{NODE_ENV: "development", PUBLIC_URL: ""}
Reproduction repository:
Problem description:
When I run my package.json script I cant get my custom variable, it only works when I use REACT_APP_* variables or NODE_ENV
Suggested solution:
create process env variables for every custom variable.
Kent C. Dodds commented
This is actually how react-scripts works. It's an intentional feature. cross-env is doing things correctly. It's just that react-scripts wont make all env variables available to your frontend code.
Read more: https://create-react-app.dev/docs/adding-custom-environment-variables/
Good luck :)