Implement redux.
This commit is contained in:
16
pages/api/auth/logout.js
Normal file
16
pages/api/auth/logout.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { serialize } from 'cookie';
|
||||
import { AUTH_COOKIE_NAME } from 'lib/constants';
|
||||
|
||||
export default async (req, res) => {
|
||||
const cookie = serialize(AUTH_COOKIE_NAME, '', {
|
||||
path: '/',
|
||||
httpOnly: true,
|
||||
maxAge: 0,
|
||||
});
|
||||
|
||||
res.statusCode = 303;
|
||||
res.setHeader('Set-Cookie', [cookie]);
|
||||
res.setHeader('Location', '/login');
|
||||
|
||||
return res.end();
|
||||
};
|
||||
Reference in New Issue
Block a user