Images are not loading due to 400 error #80899
-
I'm using Next.js and running into an issue where none of my images are loading. I'm using the component from next/image, and every image gives this error in the console: Failed to load resource: the server responded with a status of 400 (Bad Request) I've been stuck on this for a couple of days and can't figure out what's wrong. My setup:
What I've tried:
Example code: import Image from "next/image";
export default function YDALogo({ className }: { className?: string }) {
return <Image src="/logo.jpg" alt="App logo" width={500} height={500} />;
} I confirmed that the image exists in public/my-image.png, and I'm not getting any 404s — just a 400 Bad Request error. Has anyone run into this or have any ideas what I might be missing? I’m completely stuck. These are my dependencies: "dependencies": {
"@fortawesome/free-solid-svg-icons": "^6.7.2",
"@fortawesome/react-fontawesome": "^0.2.2",
"@prisma/client": "^6.10.1",
"@types/bcrypt": "^5.0.2",
"bcrypt": "^6.0.0",
"clsx": "^2.1.1",
"crypto": "^1.0.1",
"next": "15.3.3",
"next-auth": "^4.24.11",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"resend": "^4.6.0",
"tailwind-merge": "^3.3.1",
"use-debounce": "^10.0.5",
"zod": "^3.25.67"
},
"devDependencies": {
"@eslint/eslintrc": "^3.3.1",
"@svgr/webpack": "^8.1.0",
"@tailwindcss/postcss": "^4.1.10",
"@types/node": "^20.19.1",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
"daisyui": "^5.0.43",
"eslint": "^9.29.0",
"eslint-config-next": "15.3.3",
"prisma": "^6.10.1",
"tailwindcss": "^4.1.10",
"ts-node": "^10.9.2",
"typescript": "^5.8.3"
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 22 replies
-
Interesting. Do you have a middleware file? |
Beta Was this translation helpful? Give feedback.
-
Next.js 15 has some stricter behaviors with next/image. {/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={thumbnailUrl}
alt={`Thumbnail for ${item.name || 'item'}`}
className={`${styles.thumbnail} ${isEnlarged ? styles.thumbnailEnlarged : ''}`}
onLoad={() => setImageLoaded(true)}
onError={(e) => {
console.error(`Failed to load thumbnail: ${thumbnailUrl}`);
(e.target as HTMLImageElement).alt = 'Thumbnail not available';
setImageLoaded(false);
}}
/> If this works, the issue is specifically with next/image handling. 2. Disable Image Optimization module.exports = {
images: {
unoptimized: true,
},
}; If this works, the problem is with the optimizer - possibly conflicting with how next dev serves images in your environment. |
Beta Was this translation helpful? Give feedback.
-
Ah got it - that makes sense! The reason src="/auth_layout.jpeg" That should work perfectly with next/image (or even a regular |
Beta Was this translation helpful? Give feedback.
.*\\.[^/]+$
is a regex that matches anything with a file extension (e.g., .jpg, .png, .css, .woff2, .webmanifest, etc.).