title: How to manage and send httpOnly stored jwt cookies within React and Axios
body: <p>I'm actively trying to gain knowledge on <code>httpOnly</code> cookie and found out lots of article on it that why should we use it.</p>
  <p>But I haven't seen any practical example of how to work with it. From few trial and error, I came to knew that we can't set <code>httpOnly</code> flag in browser and needed to be done on server. So I, used <code>cookie-parser</code> library accordingly:</p>
  <pre><code>const express = require('express');
  var cookieParser = require('cookie-parser');
  const app = express();
  app.use(cookieParser());
  
  app.post('/generateToken', (req, res) =&gt; {
      res.cookie('AccessToken', JWT_AUTH_TOKEN, {
          expires: new Date(new Date().getTime() + 30 * 1000),
          sameSite: 'strict',
          httpOnly: true,
          
      })
      res.cookie('RefreshToken', JWT_REFRESH_TOKEN, {
          expires: new Date(new Date().getTime() + 31557600000),
          sameSite: 'strict',
          httpOnly: true,
      }).send(&quot;hello&quot;)
      
  });
  
  app.listen(process.env.PORT || 5050);
  </code></pre>
  <p>By this I successfully get the cookie stored in my browser with all the property like <code>sameSite</code>, <code>HttpOnly</code> except <code>secure:true</code> as I'm on local host. But the problem is as we cant access these <code>httpOnly</code> token with javascript, How do I send it to particular routes with proper header like below</p>
  <pre><code>let token = req.headers['authorization'];
  </code></pre>
  <p>and send httpOnly cookie <code>refreshToken</code> to lets say <code>/refresh</code> Route to get new <code>accessTokens</code> with Axios or whats the way of doing it?</p>