adrianhajdin / project_professional_portfolio

This is a code repository for the corresponding YouTube video. In this tutorial we are going to build and deploy a real time chat application. Covered topics: React.js, SCSS, Framer Motion, Sanity
https://jsmastery.pro
2.07k stars 496 forks source link

Uncaught Error: Configuration must contain `projectId` #34

Open samyak1999 opened 2 years ago

samyak1999 commented 2 years ago

The above error occurred(displayed in the console) when I tried to integrate sanity bank-end with the react app. React app starts with a blank screen with no error in terminal. I am unable to debug the issue.

samyak1999 commented 2 years ago

Issue arose while using variables from .env file . How to import values from .env file into client.js ?

CloAk-64bit commented 2 years ago

I have run into this same problem but if you remove the process.env.REACT.... and just put your projectId in as a string it will work but best practices doesnt allow this so apperantly what ive read is that it will work in production but in development you either have to change the .env to .env.example or development. and yes ive tried this aswell neither worked for me so just placed the token in the env and made it public string

Anirudh-A-V commented 2 years ago

Does your project have a .gitignore file in it?? If not create it. Use this for reference.

Now install the dependency npm install dotenv --save Next, add the following line to your app require('dotenv').config()

Then delete the .env file and input the environment variables again... This should solve the issue...

CloAk-64bit commented 2 years ago

Yes it does but plus I did try that but I ended with the same results the only thing that worked for me was this command in powershall or even in your vscode: ($env:REACT_APP_NOT_SECRET_CODE = "abcdef") -and (npm start) if use yarn just change that bit. But I think it introduced a related bug or not I could be wrong. But thanks man managed to finish my app by then went with strapi insted

MagicFishgit commented 2 years ago

The solution to this is much more simple. The author uses REACTAPPSANITYPROJECTID=yourvalue. Just remove the extra underscores so it looks like this REACT_APP_SANITY_PROJECT_ID=yourvalue for both of the variables and remember to update them in the client.js as well and it should resume working.