R
Railwayā€¢2y ago
Lukoolios

React front end MongoDB Cannot connect

I am having issues connecting my mongoDB back end and react front end. I have store proper env variables within railway and updated url within front end to reference new backend url. These are the error messages i have recieved: Invalid Host header - This is from the front end Cannot GET / - This is from the back end id: 929d0c8e-0db8-48c7-960f-034b7b907500
42 Replies
Percy
Percyā€¢2y ago
Project ID: 929d0c8e-0db8-48c7-960f-034b7b907500
Brody
Brodyā€¢2y ago
show me a screenshot of your service variables please? why would you shoe me the variable values?? this is a public thread
Lukoolios
Lukooliosā€¢2y ago
Sorry Iā€™m still very new to this Want me to resend but hidden?
Brody
Brodyā€¢2y ago
delete the database variables and set up a variable reference for MONGO_URL https://docs.railway.app/develop/variables#reference-variables then, id like another screenshot with the values kept hidden
Lukoolios
Lukooliosā€¢2y ago
Brody
Brodyā€¢2y ago
wait, where is your mongodb plugin?
Lukoolios
Lukooliosā€¢2y ago
I was unaware i needed that, i was following a guide and didnt see that step again I am very new to the deployment aspect though i do see something now about running railway connect to start shell?
Brody
Brodyā€¢2y ago
okay then if you dont have a mongo database, what are you using for the variable value?? send me the guide please
Lukoolios
Lukooliosā€¢2y ago
Lukoolios
Lukooliosā€¢2y ago
i do have a database set up, i am able to run it locally i guess im confused on your previous question abou tthe plugin then? the only thing I havent done is run railway connect, but im unsure where that command is supposed to be ran or is that an alternative to setting the env variables?
Brody
Brodyā€¢2y ago
you need to add a database plugin to your railway project
Lukoolios
Lukooliosā€¢2y ago
So by that do you mean the backend files as one project and the front end in another? becuase i have done that and they are both available under the file the variables are attached to the backend files
Brody
Brodyā€¢2y ago
bro stop overthinking this
Lukoolios
Lukooliosā€¢2y ago
lol sorry
Brody
Brodyā€¢2y ago
just add a database plugin to your project, click the "+ New" button at the top right
Lukoolios
Lukooliosā€¢2y ago
well why didnt i see that before lmao
Brody
Brodyā€¢2y ago
good question delete the database variables and set up a variable reference for MONGO_URL https://docs.railway.app/develop/variables#reference-variables then, id like another screenshot with the values kept hidden 3rd times the charm
Lukoolios
Lukooliosā€¢2y ago
Brody
Brodyā€¢2y ago
yay
Lukoolios
Lukooliosā€¢2y ago
wooo lmao
Brody
Brodyā€¢2y ago
now make sure you are using MONGO_URL in your code
Lukoolios
Lukooliosā€¢2y ago
alright, ive updated the backend to reflect the ref to MONGO_URL So i can view the collections via the mongodb plugin, however i am still receiving the same errors when visiting the back and front end urls. Just to make sure I referenced properly, these references should still be stored in the .env file? or refferenced directly using the ${{}} sytax in the server file
Brody
Brodyā€¢2y ago
nodejs backend right?
Lukoolios
Lukooliosā€¢2y ago
yes
Brody
Brodyā€¢2y ago
then you use process.env.MONGO_URL
Lukoolios
Lukooliosā€¢2y ago
right did that,
Brody
Brodyā€¢2y ago
show me the errors
Lukoolios
Lukooliosā€¢2y ago
Lukoolios
Lukooliosā€¢2y ago
Brody
Brodyā€¢2y ago
do you have a link to your frontend repo
Lukoolios
Lukooliosā€¢2y ago
GitHub
GitHub - LukeLarson2/price-book-frontend
Contribute to LukeLarson2/price-book-frontend development by creating an account on GitHub.
Lukoolios
Lukooliosā€¢2y ago
ahh ok
Brody
Brodyā€¢2y ago
let me know when done so I can check your work lol
Lukoolios
Lukooliosā€¢2y ago
ok I think i got it right changes are pushed I appreciate the understanding and help
Brody
Brodyā€¢2y ago
looks good to me
Lukoolios
Lukooliosā€¢2y ago
Still getting the same errors
Brody
Brodyā€¢2y ago
show console errors
Lukoolios
Lukooliosā€¢2y ago
Oh never mind, just needed a little more time processing, thank you for the help, much appreciated
Brody
Brodyā€¢2y ago
oh yeah the switch over so all good?
Lukoolios
Lukooliosā€¢2y ago
yea its working šŸ‘
Brody
Brodyā€¢2y ago
awesome!
Want results from more Discord servers?
Add your server