问题
I'm using OpenShift with node js and mongo db.
I'd like to develop updates locally and then push them to the server.
How can I develop node js locally and connect to a remote mongo db.
I've tried port forwarding. This forwards everything for some reason so runs node js server instance. Which is no good. I want to run the localhost node js.
rhc port-forward appname
This port forwads just mongodb, but if I then run node js in a separate terminal, it's unable to connect.
rhc port-forward appname -s mongodb
Do i even need port forwarding, or will the correct mongo db connection string solve this?
Hope somebody clever out there knows the answer.
回答1:
Ok, solved this.
First enable port forwarding for just mongo db.
rhc port-forward appname -s mongodb
Use a local db connection string
mongodb://admin:ABCDEFGHIJ@127.0.0.1:27017/databasename
Run node
node server.js
Port forwarding will forward just mongo db via localhost to it's remote location.
来源:https://stackoverflow.com/questions/42937519/how-do-i-develop-node-js-on-localhost-whilst-connecting-to-remote-mongo-db