Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

No custom variable available without REACT_APP_ prefix #220

Closed
michalpaukert opened this issue Nov 30, 2019 · 1 comment
Closed

No custom variable available without REACT_APP_ prefix #220

michalpaukert opened this issue Nov 30, 2019 · 1 comment

Comments

@michalpaukert
Copy link

  • cross-env version: 6.0.3
  • node version: 12.13.0
  • npm (or yarn) 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.

@michalpaukert michalpaukert changed the title No custom variable No custom variable available without REACT_APP_ prefix Nov 30, 2019
@kentcdodds
Copy link
Owner

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 :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants