mongodb's collections data can't display on my webpage.
After import a json file, collections have a contacts . when I use "docker run" command, my localhost/contacts don't display any data.
30 Replies
Project ID:
c7cb0789-9eba-454f-8499-d7ee14e026af
c7cb0789-9eba-454f-8499-d7ee14e026af
have anyone here?
are you passing in the mongodb environment variables to the docker run command?
yes, I use "docker run -p 8080:8080 -e PORT=8080 -e MONGODB_URI="mongodb://mongo:[email protected]:7978" hello_crow:latest "
And my localhost:8080 display a html fine.
@Brody are you still here?
you have to stop with the spam pings
what relation with spam pings?
#🛂|readme #5
I am sorry for you.
but could you continue help sloving my question?
chill
ok, my english is not so good.
anyway, why contacts under collections do not display on webpage?
usually the environment variable is called
MONGO_URL
so use that, both in the command line args and in your codeyes.
in main.cpp, use below commands get contacts:
and use these commands to server contacts page:
why do you have a hardcoded host and port
i write it according a course, when open 8080 port, the page can display, otherwise, it can't display.
does this work on localhost?
yes, localhost:8080 and localhost:8080/about have a page.
show me a screenshot of your railway service variables
^
so i should only have MONGO_URL.
your code is not using
MONGO_URL
please more in detail
your code is not using the
MONGO_URL
environment variableso i should change
string mongoConnect=std::string(getenv("MONGODB_URI"));
to MONGODB_URL
? and delete other variables?i understand english is not your first language, so please read over my message carefully
ok, change to MONGO_URL
yes
thank you so much.this issue trouble me one day. bye.
your app works on railway now?
yes, it works after I change
getenv
and conn[][]
.I don't know what 's string after '@' in MONGO_URL? I am wrong with conn[string afer@][].