title: Node Express setting cookies
body: <p>I may be misunderstanding here.</p>
  
  <p>I have a node server running at <code>localhost:3000</code>, and a React app running at <code>localhost:8080</code>.</p>
  
  <p>The React app is making a <code>get</code> request to the node server - my server code for this looks like:</p>
  
  <pre><code>const cookieParser = require('cookie-parser');
  const crypto = require('crypto');
  const express = require('express');
  
  const app = express();
  
  app.use(cookieParser());
  
  app.get('/', function (req, res) {
      let user_token = req.cookies['house_user']; // always empty
  
      if (user_token) {
          // if the token exists, great!
      } else {
          crypto.randomBytes(24, function(err, buffer) {
              let token = buffer.toString('hex');
              res.setHeader('Access-Control-Allow-Origin', 'http://localhost:8080');
              res.cookie('house_user', token, {maxAge: 9000000000, httpOnly: true, secure: false });
              res.send(token);
          });
      }
  });
  
  app.listen(3000, () =&gt; console.log('Example app listening on port 3000!'))
  </code></pre>
  
  <p>I'm trying to set the <code>house_user</code> token, so that I can later keep track of requests from users.</p>
  
  <p>However, the token is not being set on the user (request from <code>localhost:8080</code>) - the <code>house_user</code> token is always empty (in fact, <code>req.cookies</code> is entirely empty). Do I need to do something else?</p>