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
Project ID:
929d0c8e-0db8-48c7-960f-034b7b907500
show me a screenshot of your service variables please?
why would you shoe me the variable values??
this is a public thread
Sorry Iām still very new to this
Want me to resend but hidden?
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 hiddenwait, where is your mongodb plugin?
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?
okay then if you dont have a mongo database, what are you using for the variable value??
send me the guide please
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?
you need to add a database plugin to your railway project
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
bro stop overthinking this
lol sorry
just add a database plugin to your project, click the "+ New" button at the top right
well why didnt i see that before lmao
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 charmyay
wooo
lmao
now make sure you are using
MONGO_URL
in your codealright, 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 filenodejs backend right?
yes
then you use
process.env.MONGO_URL
right did that,
show me the errors
do you have a link to your frontend repo
GitHub
GitHub - LukeLarson2/price-book-frontend
Contribute to LukeLarson2/price-book-frontend development by creating an account on GitHub.
you will want to follow this guide
https://help.railway.app/project-help/f9v3gkPQRy4UShk5SnoPDH/getting-your-create-react-app-running-on-railway/qHRsgxa5n57xLp1yVgk9fP
ahh ok
let me know when done so I can check your work lol
ok I think i got it right
changes are pushed
I appreciate the understanding and help
looks good to me
Still getting the same errors
show console errors
Oh never mind, just needed a little more time processing, thank you for the help, much appreciated
oh yeah the switch over
so all good?
yea its working š
awesome!