Images in `public` folder not loading
Answered
Spectacled bear posted this in #help-forum
Spectacled bearOP
Heyo, my images in my NextJS 15.2.0 are not loading. Any idea or solution why?
<Image src="/brand/transparent/logo_light.png" alt="Alt Text" width={500} height={500} />
Answered by B33fb0n3
thanks for sharing. When you request your files, this request will also run through the middleware. Either fully exclude them (by checking if the path starting with "/brand/" or serve them through a CDN (that would be even better)
7 Replies
Spectacled bearOP
import {NextRequest, NextResponse} from "next/server";
export const config = { matcher: ['/((?!api|home|login|register|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)'] };
export async function middleware(request: NextRequest) {
const { nextUrl, cookies } = request;
...
}
@Spectacled bear import {NextRequest, NextResponse} from "next/server";
export const config = { matcher: ['/((?!api|home|login|register|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)'] };
export async function middleware(request: NextRequest) {
const { nextUrl, cookies } = request;
...
}
thanks for sharing. When you request your files, this request will also run through the middleware. Either fully exclude them (by checking if the path starting with "/brand/" or serve them through a CDN (that would be even better)
Answer
Spectacled bearOP
It works. But in 15.1 it works without adding it. I think it was included in _next/static.
or? 

happy to help