0

I'm building a dapp and when I'm trying to add the moralis provider to my code I get this error "Uncaught (in promise) ReactMoralisError: Provide a "appId" provided to ", which is odd because I already provided the appId, I would appreciate any tip on how to fix it.

my app.js contains:

import './App.css';
import { MoralisProvider } from "react-moralis";

function App() {
  const moralisServerUrl = process.env.REACT_APP_MORALIS_SERVER_URL;
  const moralisAppId = process.env.REACT_APP_MORALIS_APP_ID;
  return (
    <MoralisProvider appId={moralisAppId} serverUrl={moralisServerUrl}>
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <p>
            Edit <code>src/App.js</code> and save to reload.
          </p>
          <a
            className="App-link"
            href="https://reactjs.org"
            target="_blank"
            rel="noopener noreferrer"
          >
            Learn React
          </a>
        </header>
      </div>
    </MoralisProvider>
  );
}

export default App;

and my env file contains:

REACT_APP_MORALIS_SERVER_URL=https://XXXXXX.usemoralis.com:2053/server
REACT_APP_MORALIS_APP_ID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

and this is the error:

Uncaught (in promise) ReactMoralisError: Provide a "appId" provided to <MoralisProvider>
    at new ReactMoralisError (Errors.ts:4:1)
    at _useMoralisInit.ts:66:1
    at step (tslib.es6.js:102:1)
    at Object.next (tslib.es6.js:83:1)
    at tslib.es6.js:76:1
    at new Promise (<anonymous>)
    at __awaiter (tslib.es6.js:72:1)
    at _useMoralisInit.ts:53:1
    at _useMoralisInit.ts:100:1
    at commitHookEffectListMount (sort.js:9:1)
TylerH
  • 20,799
  • 66
  • 75
  • 101
pardis.ti
  • 113
  • 7
  • How much debugging have you done? What happens if you replace `moralisAppId` with the actual key? Does it work, or do you get the same error? That answer will lead you to the next step. – Andy Jul 17 '22 at 12:28
  • I was suggested to hardcode the two variable (REACT_APP_MORALIS_SERVER_URL, REACT_APP_MORALIS_APP_ID) which I did and nothing changed not even a new error. – pardis.ti Jul 17 '22 at 12:33

1 Answers1

0

This will do the work, and in production make sure to add environment variables.

https://forum.moralis.io/t/solved-web3authentication-fails-when-adding-an-env-file/14343/11

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 25 '22 at 08:29