From 4ab0898c3bbb2546982a2b82c6800b0a42ce1226 Mon Sep 17 00:00:00 2001 From: suwonthugger <127329855+suwonthugger@users.noreply.github.com> Date: Sun, 10 Nov 2024 18:50:02 +0900 Subject: [PATCH] =?UTF-8?q?[Common]=20[Chore]=20=EB=AF=B8=EB=93=A4=20?= =?UTF-8?q?=EC=9B=A8=EC=96=B4=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/middleware.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts index 47092dd..8dd3da4 100644 --- a/apps/web/middleware.ts +++ b/apps/web/middleware.ts @@ -1,4 +1,3 @@ -// middleware.js import { NextRequest, NextResponse } from 'next/server'; export function middleware(req: NextRequest) { @@ -6,10 +5,7 @@ export function middleware(req: NextRequest) { const host = req.headers.get('host') || ''; const pathname = req.nextUrl.pathname; - // 모바일 서브도메인으로 이미 접속한 경우 무시 - if (host.startsWith('m.')) { - return NextResponse.next(); - } + console.log(`Middleware invoked for host: ${host}, path: ${pathname}`); // 모바일 기기 감지 const userAgent = req.headers.get('user-agent') || ''; @@ -18,6 +14,8 @@ export function middleware(req: NextRequest) { userAgent, ); + console.log(isMobile); + if (isMobile) { // 모바일 서브도메인으로 리다이렉션 url.hostname = `m.${url.hostname}`;