Hi so I have tried to create my own react app with a server and client side (full stack). It is not based on anything I saw on scrimba so this is taking it a bit further. My app connects to postgresql to store information in a database. Wwhen i start my app seperately in a split terminal it works fine, as long as i start server, then client. However, when I try to use a common start in my root package json file, with concurrently dependancy and other methods, it always fails as there is a failure of database authorisation. Basically I think I need to have a common start command which starts server first and then starts client afterwards (i think) but I have ot had any success with various combinatins. Has anyone faced this issue before with full stack and a common start command?
#backend and frontend not working concurrently owing to failure to connect to database
28 messages · Page 1 of 1 (latest)
Can you share your start command script used with concurrently?
and which desktop OS are you using?
Also will be helpful to see the folder structure and/or repo iff possible.
im using windows. this is the start command in my root package.json "scripts": {
"build": "if-env TYPE=server && (cd server && npm install) || (cd client && npm install)",
"start": "concurrently "npm run start-server" "npm run start-client"",
"start-server": "node ./server/server.js",
"start-client": "wait-on http://localhost:8000 && npm run client",
"client": "cd client && npm start"
},
This is a breakdown of the code setup...
Thanks
Does start-server and start-client work individually from root?
becasue I doubt your client script works
also your concurrently script/command might not be in the correct format as I don't see you escaping quotes, but thats the later problem to solve.
Yes they work fine separately if I start server first and then client
Though haven't double checked since that last code update but has worked consistently with separate starts
I meant does npm run client work from the root?
No it doesn't no..
Sorry not at laptop atm...
But nothing works from the root
Only from client and server separately
so even before trying to run them concurrently, you should get those individual scripts running from the root. If they can't work on their own, how can they run together?
They do work on their own, just not from the root
I use npm run server from server and npm run client and they both open up
And the app works fine
Hmm you don't get my point.
if you want the concurrent script to work, you need to first make sure the individual scripts work which the concurrent try to run.
So first you need to fix npm run client at root.
"client": "cd client && npm start"
this you need to fix first
Ok I will give this a go... won't be for few hours tho.... thanks for your help !
hi
{
"name": "deployed-to-do-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "if-env TYPE=server && (cd server && npm install) || (cd client && npm install)",
"start": "concurrently "npm run server" "npm run client"",
"server": "cd server && npm start",
"client": "cd client && npm start"
},
"dependencies": {
"if-env": "^1.0.4"
},
"devDependencies": {
"concurrently": "^8.2.0",
"wait-on": "^7.0.1"
}
}
i tried this... and it worked! you were right i juts had to take a closer look at what would work for either client and server from the root