I would need more code to understand what the problem may be stemming from. Your configuration file seems to be fine, therefore I can’t provide a clear solution for this. So after checking out the Cloudinary and Next JS documentation, here are a few things I want you to try out:
- Ensure that you have the
next-image
package installed in you Next JS project. If not, install it using your package manager.
- Try rebuilding your application with the
npm run build
before running it again. This may solve your problem.
- Next, try re-initializing the
next.config.js
file with the following code:
next.config.js
:
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}
module.exports = nextConfig
const withImages = require('next-images');
module.exports = withImages({
images: {
domains: [
'res.cloudinary.com',
'avatars.githubusercontent.com',
'lh3.googleusercontent.com',
],
},
});
- If this still doesn’t work try creating a new test project. Re-initialize the
next.config.js
file with the above code and try create a new page in your project as:
Page.tsx
:
import Image from 'next/image';
export default function Page() {
return (
<div>
<h1>Next.js Image Test</h1>
<Image
src="https://res.cloudinary.com/demo/image/upload/v1/samples/sample"
alt="Cloudinary Image"
/>
</div>
);
}
Finally, build the project and navigate to http://localhost:3000/Page
. Hopefully, you should no longer experience issues with the image display from Cloudinary.