From f468fe70d97b3f86dd6abe46ee5b83c522ea20ef Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Tue, 27 Jun 2023 12:48:51 +1000 Subject: [PATCH] feat: redirect to https://hunt.deno.land (#305) * feat: redirect to new host * better --- routes/_middleware.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/routes/_middleware.ts b/routes/_middleware.ts index 56c57b488..8ba33507b 100644 --- a/routes/_middleware.ts +++ b/routes/_middleware.ts @@ -2,7 +2,8 @@ import { MiddlewareHandlerContext } from "$fresh/server.ts"; import { walk } from "std/fs/walk.ts"; import { getSessionId } from "kv_oauth"; -import { setRedirectUrlCookie } from "@/utils/redirect.ts"; +import { redirect, setRedirectUrlCookie } from "@/utils/redirect.ts"; +import { Status } from "std/http/http_status.ts"; export interface State { sessionId?: string; @@ -18,7 +19,12 @@ export async function handler( req: Request, ctx: MiddlewareHandlerContext, ) { - const { pathname } = new URL(req.url); + const { pathname, hostname } = new URL(req.url); + + if (hostname === "saaskit.deno.dev") { + return redirect("https://hunt.deno.land", Status.Found); + } + // Don't process session-related data for keepalive and static requests if (["_frsh", ...staticFileNames].some((part) => pathname.includes(part))) { return await ctx.next();