title: Nextjs- api routes , How to remove a cookie from header?
body: <p>I have two API routes which I want to set two cookies in <code>/api/login.js</code> and remove them in <code>/api/logout.js</code>.</p>
  
  <p>so this is my login API:</p>
  
  <pre><code>import { serialize } from 'cookie';
  
  export default async (req, res) =&gt; {
    res.setHeader('Set-Cookie', [
      serialize('mytoken1', 'mytoken1Value', {
        path: '/',
      }),
      serialize('mytoken2', 'mytoken2Value', {
        path: '/',
      }),
    ]);
  
    res.writeHead(302, { Location: '/' });
    res.end();
  }
  </code></pre>
  
  <p>and this is my logout API:</p>
  
  <pre><code>export default async (req, res) =&gt; {
    res.removeHeader('Set-Cookie')
  
    res.writeHead(302, { Location: '/api/login' });
    res.end();
  }
  </code></pre>
  
  <p>but the logout doesn't remove the cookies so I still can see them in <strong>_app.js</strong> ---console.log(req.headers.cookie)--- when I reload the page. Do you know how to remove a cookie in this situation?</p>