instapy-dashboard
instapy-dashboard copied to clipboard
Cannot read property 'split' of undefined
Hello,
I don't know anything about JS and I get this error. I think it is not finding my .env, right?
C:\Users\Administrator\Dashboard>npm start
> [email protected] start C:\Users\Administrator\Dashboard
> concurrently --kill-others-on-fail "react-scripts start" "npm run server"
[1]
[1] > [email protected] server C:\Users\Administrator\Dashboard
[1] > node ./src/services/server.js
[1]
[1] C:\Users\Administrator\Dashboard\src\services\server.js:15
[1] const allowedHosts = process.env.ALLOWED_HOSTS.split(' ')
[1] ^
[1]
[1] TypeError: Cannot read property 'split' of undefined
[1] at Object.<anonymous> (C:\Users\Administrator\Dashboard\src\services\ser
ver.js:15:48)
[1] at Module._compile (internal/modules/cjs/loader.js:701:30)
...
```
Hey, sounds like it, do you have a .env file in the root folder of the project?
With Project you mean the dashboard, right? I have a file "test.env" in "C:\Users\Administrator\Dashboard" where the dashboard files are.
the .env file requires to be a hidden file, take a look https://www.computerhope.com/issues/ch000009.htm
It didn't work. Same error. Do I have to change anything in server.js or any other file? I didn't find a config.js
I solved my problem with
require('dotenv').config({path:'C:\\Users\\Administrator\\Dashboard\\.env.test'}) in server.js.
But now I have the same issue like others that the Dashboard is only loading. I use INSTAPY_FOLDER=\Users\Administrator\InstaPy in the .env. I can find my logs and db there.
In cmd it says :
[0] Note that the development build is not optimized. [0] To create a production build, use npm run build.
Any idea?
Sorry mate, I can solve any issue using *nix / MacOS, but I'm the worst using Windows.
I'm getting the exactly same error, but I'm on fedora 29. Just figured out what is happening: The error was because I didn't set ALLOWED_HOSTS on .env file, coz I run instapy on DigitalOcean, so, no localhost:3000. How can I set up the .env in a way that only my IP (not DO's) can access it?
hey @mateuspestana , you could do that with a firewall, CORS is just for source/target resource control.
I'm going to add a credentials control this month.
Sorry to hijack the conversation but my question is kind of related.
How do I allow any and all access to the dashboard?
I run it locally on my rpi, I don't care much about ALLOWED_HOSTS or access control, I want it available to all the devices on the local network.
I tried simply taking out the if test in server.js (L13-15), but that doesn't seem to do the trick.
EDIT:
Got it to work following #9, that is by setting the REACT_APP_API_ENTRY_POINT in the .env file to http://<server_IP>:3000 rather than having localhost.
Can access them now from any device on the local network.