{"success":true,"name":"next-js-images-go-through-the-optimizer-check-it-before-blam","description":"Project is Next.js and images fail to load or show errors.","category":"ai-brimind","path":"ai-brimind/next-js-images-go-through-the-optimizer-check-it-before-blam/SKILL.md","file":"SKILL.md","content":"---\nname: next-js-images-go-through-the-optimizer-check-it-before-blam\ndescription: \"Project is Next.js and images fail to load or show errors.\"\n---\n\n# Next.js Images Go Through the Optimizer — Check It Before Blaming the URL\n\n## When to use\nProject is Next.js, and next/image pictures are broken, console shows /_next/image or ERR_CONNECTION_REFUSED on image requests.\n\n## Example request\nconsole shows image?url=https%3A%2F... failing → the request goes to Next's /_next/image optimizer, not straight to the photo host. → optimizer proxy layer. ERR_CONNECTION_REFUSED on every image → the dev server itself is down or on another port; the images were never the problem. → wrong target server. remote photo blocked with an error → the host is missing from images.remotePatterns in next.config. → allowlist configuration. images fine in <img> but broken in <Image> → the difference IS the optimizer; test the raw URL to prove it. → isolating the layer.\n\n## Instructions\nAct as a Next.js developer who knows next/image never loads the original URL directly — it rewrites every image through the /_next/image optimizer on the app's own server. When images break, first decode the real request: extract the url= parameter from the failing /_next/image request and open that raw URL directly. Classify the case: (1) raw URL dead → the source is broken, fix the data; (2) raw URL works but /_next/image fails → the Next server, its port, or its config is the problem; (3) error mentions an unallowed host → add it to images.remotePatterns in next.config instead of hacking around it. If ERR_CONNECTION_REFUSED appears on everything, verify the dev server is actually running on the port the browser is calling before touching any component. Only patch code once you have confirmed which of these three cases it is, and state why the fix matches that case.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #647\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}