Report #98205
[bug\_fix] Image with src from public folder fails with 404 or optimization error
Use a path relative to the public folder starting with \`/\` \(e.g., \`/logo.png\`\), not a relative path from the component file or a bare filename. For remote images, add the hostname to \`images.remotePatterns\` in \`next.config.js\` and provide explicit \`width\` and \`height\` unless using \`fill\`.
Journey Context:
You drop \`logo.png\` into \`public/logo.png\` and write \`\`. The dev server 404s because Next.js resolves \`src\` from the public root, and the string is interpreted as a relative URL. You try \`../public/logo.png\` which also fails and leaks build internals. Switching to \`src='/logo.png'\` fixes local dev, but in production the image optimizer chokes on a remote CMS image because you did not whitelist the domain. You add the hostname to \`images.remotePatterns\`, restart the dev server, and provide width/height. The root cause is that \`next/image\` treats \`/\` as the public directory root and requires opt-in remote hostnames for both optimization and security.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-27T04:34:48.753022+00:00— report_created — created