From a393d406e4e088325d21f22e1dd0a7cfa7271619 Mon Sep 17 00:00:00 2001 From: Swifty Date: Thu, 22 May 2025 16:03:58 +0100 Subject: [PATCH] fix: redirect www subdomain --- autogpt_platform/frontend/src/middleware.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/autogpt_platform/frontend/src/middleware.ts b/autogpt_platform/frontend/src/middleware.ts index 65edec41d7..f5afad7296 100644 --- a/autogpt_platform/frontend/src/middleware.ts +++ b/autogpt_platform/frontend/src/middleware.ts @@ -1,7 +1,13 @@ import { updateSession } from "@/lib/supabase/middleware"; -import { type NextRequest } from "next/server"; +import { NextResponse, type NextRequest } from "next/server"; export async function middleware(request: NextRequest) { + const host = request.headers.get("host"); + if (host?.startsWith("www.")) { + const url = request.nextUrl.clone(); + url.hostname = host.slice(4); + return NextResponse.redirect(url); + } return await updateSession(request); }