// pages/api/logout.js

import { withIronSessionApiRoute } from "iron-session/next"

export default withIronSessionApiRoute(
  function logoutRoute(req, res, session) {
    req.session.destroy()
    res.redirect('/')
  },
  {
    cookieName: "myapp_cookiename",
    password: process.env.SECRET_KEY,
    cookieOptions: {
      secure: process.env.NODE_ENV === "production",
    },
  },
)

 

GitHub: https://github.com/Sokhavuth/nblog

Vercel: https://khmerweb-nblog.vercel.app/admin/user