From c553382264596753eea0cb368c8e7ec6b0513063 Mon Sep 17 00:00:00 2001 From: Mathias Oterhals Myklebust Date: Tue, 10 Sep 2024 08:53:57 +0200 Subject: [PATCH] refactor: http status code constants --- src/middleware.ts | 3 ++- src/utils/http.ts | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 src/utils/http.ts diff --git a/src/middleware.ts b/src/middleware.ts index dd4e5e816..b2b3aad82 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -1,6 +1,7 @@ import { NextRequest, NextResponse } from "next/server"; import { client } from "../studio/lib/client"; import { RedirectSparsePage } from "../studio/lib/payloads/redirect"; +import { HTTP_STATUSES } from "./utils/http"; export async function middleware(request: NextRequest) { const slug = request.nextUrl.pathname; @@ -12,7 +13,7 @@ export async function middleware(request: NextRequest) { if (redirect !== null) { return NextResponse.redirect( new URL(redirect.destination, request.url), - 307, + HTTP_STATUSES.TEMPORARY_REDIRECT, ); } } diff --git a/src/utils/http.ts b/src/utils/http.ts new file mode 100644 index 000000000..e209a9d4f --- /dev/null +++ b/src/utils/http.ts @@ -0,0 +1,3 @@ +export const HTTP_STATUSES = { + TEMPORARY_REDIRECT: 307, +};