Next.js Discord

Discord Forum

nextjs assets nested dir asset not found

Answered
Asiatic Lion posted this in #help-forum
Open in Discord
Asiatic LionOP
images under public directly are served as expected. but /public/dir/file.svg is not found

/public/file.svg ( this works )
/public/files/file.svg ( doesn't work )

any one have this issue before ?
Answered by Asiatic Lion
issue was from my side. I've updated middleware with some logics. and found error there.

fixed by trigger if this a file extension e,g .png, ...etc to forward the request directly

  if (/\.[a-zA-Z0-9]+$/.test(url.pathname)) {
    return NextResponse.next();
  }
View full answer

1 Reply

Asiatic LionOP
issue was from my side. I've updated middleware with some logics. and found error there.

fixed by trigger if this a file extension e,g .png, ...etc to forward the request directly

  if (/\.[a-zA-Z0-9]+$/.test(url.pathname)) {
    return NextResponse.next();
  }
Answer