I'm learning to use node.js and I wrote a little test app with express and mongoose.
it working perfect on my local machine. but after I uploaded it to Appfog, the DB start to behave very strange. as you can see here:
the first change seems te happend (sometimes), but after that, it act vary weird. press F5 few time and it show the new change and sometimes it doesn't
more than that, sometime I open the app after a while and the change it there, but not always.
this is the app.js code
if there is any need for any other files I will gladly provide
it drivring me nuts for 2 days..
thank you in advance!
This documentation page should help: https://docs.appfog.com/languages/node
First of all, you need to change your app port to process.env.VCAP_APP_PORT. That means changing app.set('port', process.env.PORT || 3000) to app.set('port', process.env.VCAP_APP_PORT || 3000) in your app.js file.
Then, you need to rewire your database connection. First, remove the line mongourl = require('./env_settings') and replace it with the following:
var env = JSON.parse(process.env.VCAP_SERVICES);
var mongourl = ['mongodb-1.8'][0]['credentials'];
Now, your mongoose.connect(mongourl) will be properly configured for a Cloud Foundry environment instead of to your local environment, as it was configured previously.