Created
March 1, 2021 17:51
-
-
Save Ethaan/bbcce08106e5e6c68f6fe10f69bc4468 to your computer and use it in GitHub Desktop.
Revisions
-
Ethaan created this gist
Mar 1, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ import cookie from 'cookie'; // types import type { NextApiResponse, NextApiRequest } from 'next'; // mocks import { mockUser } from 'mocks/user'; const handler = (req: NextApiRequest, res: NextApiResponse) => { if (req.method === 'POST') { res.setHeader( 'Set-Cookie', cookie.serialize('token', '123456', { httpOnly: true, }) ); return res.status(200).json(mockUser()); } else { return res.status(500).send('Weirdo'); } }; export default handler;