Archived
1
0
This repository has been archived on 2024-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
code-server/src/node/routes/logout.ts

18 lines
566 B
TypeScript
Raw Normal View History

2021-05-03 21:22:29 +02:00
import { Router } from "express"
import { getCookieDomain, redirect } from "../http"
import { Cookie } from "./login"
export const router = Router()
router.get("/", async (req, res) => {
// Must use the *identical* properties used to set the cookie.
res.clearCookie(Cookie.Key, {
domain: getCookieDomain(req.headers.host || "", req.args["proxy-domain"]),
path: req.body.base || "/",
sameSite: "lax",
})
const to = (typeof req.query.to === "string" && req.query.to) || "/"
return redirect(req, res, to, { to: undefined, base: undefined })
})