     )
     next()
 
-app.use express.static path.resolve __dirname, 'dist'
-app.set 'views', './views'
-app.set 'view engine', 'jade'
+server.use express.static path.resolve __dirname, 'dist'
+server.set 'views', './views'
+server.set 'view engine', 'jade'
 
-app.get '/index.atom', (req, res) ->
+server.get '/index.atom', (req, res) ->
   lang = negotiateLang req
-  res.header 'Content-Type', 'application/atom+xml; charset=utf8'
+  res.header 'Content-Type', 'serverlication/atom+xml; charset=utf8'
   { store } = createStore()
   init(store, {}, lang).then ->
     articles = articleSelectors.containerSelector(store.getState()).articles

  ca: fs.readFileSync path.join certsPath, 'chain.pem'

if PROD
  server = https.createServer credentials, app
else
  server = app

server.listen 8081, ->
  logger.info 'Express web server listening on port 8081...'


certsPath = path.resolve '/etc/letsencrypt/live/3rdhand.info'

server = express()
server.use favicon './favicon.ico'
server.use(bodyParser.json())
server.use bodyParser.urlencoded extended: true

if DEV
  server.use (req, res, next) ->
    res.header 'Access-Control-Allow-Origin', '*'
    res.header(
      'Access-Control-Allow-Headers'
