Skip to content

Commit

Permalink
Merge pull request #110 from perimetre/dev
Browse files Browse the repository at this point in the history
feat: ignore storage in public folder
  • Loading branch information
yanikproulx authored May 6, 2024
2 parents b979da5 + ee060e7 commit 6d8a085
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

# production
/build
/public/storage

# misc
.DS_Store
Expand Down
6 changes: 5 additions & 1 deletion src/pages/_middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 6d8a085

Please sign in to comment.