NextJS ImageError: Unable to optimize image and unable to fallback to upstream image

问题描述 投票:0回答:0

我创建了中间件并在配置中间件中添加了匹配器

/((?!api|_next/static|_next/image|favicon.ico|auth/login).*)
。 当我尝试运行
npm run dev
。结果是这样的:

ImageError: Unable to optimize image and unable to fallback to upstream image
    at imageOptimizer (C:\work\internal-dashboard\node_modules\next\dist\server\image-optimizer.js:563:19)
    at async cacheEntry.imageResponseCache.get.incrementalCache (C:\work\internal-dashboard\node_modules\next\dist\server\next-server.js:238:72)
    at async C:\work\internal-dashboard\node_modules\next\dist\server\response-cache\index.js:83:36 {
  statusCode: 400
}
ImageError: Unable to optimize image and unable to fallback to upstream image
    at imageOptimizer (C:\work\internal-dashboard\node_modules\next\dist\server\image-optimizer.js:563:19)
    at async cacheEntry.imageResponseCache.get.incrementalCache (C:\work\internal-dashboard\node_modules\next\dist\server\next-server.js:238:72)
    at async C:\work\internal-dashboard\node_modules\next\dist\server\response-cache\index.js:83:36 {
  statusCode: 400
}

在我添加中间件之前这并没有发生,当我在中间件中添加配置匹配器时发生了这种情况。这是我制作的中间件上的配置匹配器:

export const config = {
  matcher: [
    '/((?!api|_next/static|_next/image|favicon.ico|auth/login).*)',
    '/partner/:path*'
  ],
};

我试图从中间件匹配器中省略

_next/image
。导致部分图片加载不出来

有办法破案吗?还是我做中间件的时候忘记了什么?

reactjs next.js middleware nextjs-image
© www.soinside.com 2019 - 2024. All rights reserved.