From 7ced408041ccc31eee371226af55bdde87992be1 Mon Sep 17 00:00:00 2001 From: ilia Date: Sun, 4 Jan 2026 13:48:49 -0500 Subject: [PATCH] refactor: Update proxy and image components to support uploads - Modified the proxy function to allow access to the "/uploads" route alongside existing public routes. - Enhanced PhotoImage and PhotoThumbnail components to handle local uploads by treating them similarly to external URLs. - Updated comments to clarify the changes made regarding uploads and public folder handling. --- components/PhotoImage.tsx | 4 ++-- components/PhotoThumbnail.tsx | 4 ++-- proxy.ts | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/components/PhotoImage.tsx b/components/PhotoImage.tsx index 9eeadff..21c5c01 100644 --- a/components/PhotoImage.tsx +++ b/components/PhotoImage.tsx @@ -5,8 +5,9 @@ import Image from "next/image" export default function PhotoImage({ src, alt }: { src: string; alt: string }) { // Handle external URLs and local paths const isExternal = src.startsWith("http://") || src.startsWith("https://") + const isLocalUpload = src.startsWith("/uploads/") - if (isExternal) { + if (isExternal || isLocalUpload) { return ( /* eslint-disable-next-line @next/next/no-img-element */ ) } diff --git a/components/PhotoThumbnail.tsx b/components/PhotoThumbnail.tsx index 1f13220..885a1a1 100644 --- a/components/PhotoThumbnail.tsx +++ b/components/PhotoThumbnail.tsx @@ -5,10 +5,11 @@ import Image from "next/image" export default function PhotoThumbnail({ src, alt }: { src: string; alt: string }) { // Handle external URLs and local paths const isExternal = src.startsWith("http://") || src.startsWith("https://") + const isLocalUpload = src.startsWith("/uploads/") return (
- {isExternal ? ( + {isExternal || isLocalUpload ? ( /* eslint-disable-next-line @next/next/no-img-element */ )}
diff --git a/proxy.ts b/proxy.ts index ac23581..fbb39e6 100644 --- a/proxy.ts +++ b/proxy.ts @@ -6,7 +6,7 @@ export async function proxy(request: NextRequest) { const pathname = request.nextUrl.pathname // Public routes - allow access - if (pathname === "/login" || pathname.startsWith("/api/auth")) { + if (pathname === "/login" || pathname.startsWith("/api/auth") || pathname.startsWith("/uploads")) { return NextResponse.next() } @@ -68,8 +68,9 @@ export const config = { * - _next/rsc (RSC payload requests) * - _next/webpack (webpack chunks) * - favicon.ico (favicon file) - * - public folder + * - uploads/ (uploaded files) + * - public folder files (images, etc.) */ - "/((?!_next/static|_next/image|_next/rsc|_next/webpack|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)", + "/((?!_next/static|_next/image|_next/rsc|_next/webpack|favicon.ico|uploads|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)", ], }