Skip to content

Instantly share code, notes, and snippets.

@realyze
Last active December 19, 2015 22:29
Show Gist options
  • Save realyze/6027692 to your computer and use it in GitHub Desktop.
Save realyze/6027692 to your computer and use it in GitHub Desktop.
Adding cookie to allow client authentication.
express = require 'express'
config = require 'config'
app = express()
app.configure ->
app.use '/static/', express.static config.static_root path.join __dirname, '/../client/build'
app.use '/static/', (req, res, next) ->
# We're requesting a non-existent static resource.
res.send 404
# Your routes...
# Default route.
app.get '/*', (req, res) ->
res.cookie 'user', JSON.stringify(req.user?.doc) or null
res.render 'index.html'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment