From ee060e792fc7802db9d6ec4a6473e8dec3411ca0 Mon Sep 17 00:00:00 2001 From: AssisrMatheus Date: Mon, 6 May 2024 13:39:20 -0400 Subject: [PATCH] feat: ignore storage in public folder --- .gitignore | 1 + src/pages/_middleware.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 86484ed..1dfa8cf 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ # production /build +/public/storage # misc .DS_Store diff --git a/src/pages/_middleware.ts b/src/pages/_middleware.ts index a40564c..5ba38f0 100644 --- a/src/pages/_middleware.ts +++ b/src/pages/_middleware.ts @@ -15,7 +15,11 @@ export function middleware(request: NextRequest) { } // Ref: https://github.com/vercel/next.js/discussions/18419#discussioncomment-1663807 - const shouldHandleLocale = !PUBLIC_FILE.test(pathname) && !pathname.includes('/api/') && locale === 'default'; + const shouldHandleLocale = + !PUBLIC_FILE.test(pathname) && + !pathname.includes('/api/') && + locale === 'default' && + !pathname.includes('/storage/'); return shouldHandleLocale ? NextResponse.redirect(`/${LANG}${pathname + href.split(pathname)[1]}`) : undefined; }