This repository has been archived on 2024-06-14. You can view files and clone it, but cannot push or open issues or pull requests.
icynet-admin/pages/api/logout.ts

20 lines
501 B
TypeScript
Raw Normal View History

2022-08-29 18:09:28 +00:00
import { NextApiRequest, NextApiResponse } from 'next';
import Cookies from 'cookies';
import { COOKIE_KEYS } from '../../lib/constants';
2022-09-11 09:31:09 +00:00
const inProd = process.env.NODE_ENV === 'production';
2022-08-29 18:09:28 +00:00
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
2022-09-11 09:31:09 +00:00
const cookies = new Cookies(req, res, { keys: COOKIE_KEYS, secure: inProd });
2022-08-29 18:09:28 +00:00
cookies.set('authorization', undefined, {
expires: new Date(0),
signed: true,
2022-09-11 09:31:09 +00:00
secure: inProd,
2022-08-29 18:09:28 +00:00
});
res.redirect('/');
}