#1 Piece of code : ExpressJS + Memcached Sessions

Works on my machine problem again!
  • Google App Engine Setup with NodeJS + ExpressJS (ok)
  • Authentication with PassportJS and a Google Strategy (ok)
  • Angular - Login (failed on Production)

Well, I started developing an app with ExpressJS running on Google Cloud Platform (here) and experienced some troubles when I tried to protect Angular routes. My code works only in local environnement. Why? Just because the ExpressJS sessions were linked to one instance and I have two instances in production … OK. But how can I solve it? Using memcached for sessions!

According to the example Express.js + Memcached Sessions on Google App Engine (here) :

Each Google App Engine application comes with a memcached service instance.

So 2 steps to success :

  • Adding memcached url in config.json : MEMCACHE_URL: memcache:11211
  • Updating server.js :