Next.js Discord

Discord Forum

Next Learn - adding auth/middleware affects image optimizer.

Unanswered
Carpenter wasp posted this in #help-forum
Open in Discord
Carpenter waspOP
Following the Learn NextJs: https://nextjs.org/learn/dashboard-app/adding-authentication
Up till here, everything worked. After I added the auth as in the docs, I get this error
`
ImageError: Unable to optimize image and unable to fallback to upstream image
    at imageOptimizer (C:\code\nextjs-dashboard\node_modules\next\dist\server\image-optimizer.js:659:19)
    at async cacheEntry.imageResponseCache.get.incrementalCache (C:\code\nextjs-dashboard\node_modules\next\dist\server\next-server.js:176:65)
    at async C:\code\nextjs-dashboard\node_modules\next\dist\server\response-cache\index.js:93:36
    at async C:\code\nextjs-dashboard\node_modules\next\dist\lib\batcher.js:41:32 {
  statusCode: 400
}
`

From what I gather, with this matcher config
export const config = {
  matcher: ['/((?!api|_next/static|_next/image|.png).*)'],
};
`

it should work, since the static image service, which next uses for image optimization and the .png files are excluded, so I am a bit lost to where this is coming from and why. Happy for ideas on how to approach such a bug

1 Reply

Carpenter waspOP
Any update?