feat: redirect to same url on login/logout
This commit is contained in:
@ -2,9 +2,14 @@ import { deleteCookie } from "https://deno.land/std@0.197.0/http/cookie.ts";
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET() {
|
||||
GET(req) {
|
||||
const url = new URL(req.url);
|
||||
|
||||
const redirect = decodeURIComponent(url.searchParams.get("redirect") || "");
|
||||
|
||||
const headers = new Headers();
|
||||
headers.append("location", "/");
|
||||
headers.append("location", redirect || "/");
|
||||
|
||||
deleteCookie(headers, "session_cookie", {
|
||||
path: "/",
|
||||
});
|
||||
|
Reference in New Issue
Block a user