Next.js Discord

Discord Forum

Accessing Public static files with i18n routing

Unanswered
Britannia Petite posted this in #help-forum
Open in Discord
Britannia PetiteOP
We have the following issue:

- We have i18n set up so that the country code is always behind the root, e.g. URL/en/my-blog
- The problem is that we reference some static files like so:

<Image
src="/my-logo.webp"
alt="some-image"
width={800}
height={400}
/>

Now the problem is that nextjs will look for the image under /us/my-logo.webp but the image is acuttally straight "under" the public folder. Hence, it will throw a 404 for the image.

How can I make it ignore the country code for these assets? I tried nextjs rewrites but could not get it to work.

Does anyone know? Thanks!

1 Reply

I think its the matcher in your middleware
try this

matcher: ["/((?!api|_next/static|_next/image|.\.png$).)"],