'Firebase: Error (auth/invalid-api-key) in live site. But works in locally

My React App is running well locally. But on live site it shows this error and loads nothing.

Uncaught FirebaseError: Firebase: Error (auth/invalid-api-key).
    at Ut (main.d108a90a.js:2:403619)
    at Bt (main.d108a90a.js:2:403758)
    at main.d108a90a.js:2:514892
    at e.instanceFactory (main.d108a90a.js:2:515499)
    at e.value (main.d108a90a.js:2:385751)
    at e.value (main.d108a90a.js:2:384861)
    at qt (main.d108a90a.js:2:404273)
    at main.d108a90a.js:2:524925
    at main.d108a90a.js:2:524981
    at main.d108a90a.js:2:80


Solution 1:[1]

In my case, My env vars are declared as:

REACT_APP_API_KEY=xxxxxx
REACT_APP_authDomain=xxxx
/....

here, the I should write REACT_APP_apikey instead of REACT_APP_API_KEY. I edited this and worked. :)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mahfuz Swaron