'Getting errors in console in Nextjs while using images from Unsplash

I am using Unsplash images in my Nextjs App. Images are loaded and showing in the app but I am getting these errors and warnings. The way I am using images I just copy the image address from Unsplash and paste the URL in the src attribute.

Here is the next.config.js file:

/** @type {import('next').NextConfig} */

const nextConfig = {
  reactStrictMode: true,
  distDir: "build",
  images: {
    domains: ["images.unsplash.com", "cdn.pixabay.com", "images.pexel.com"],
  },
};

module.exports = nextConfig;

Console error:

enter image description here

Network Tab error:

enter image description here

Note: I have also edited the next.config.js file.



Solution 1:[1]

Viewing a photo on Unsplash shows a URL of the format https://unsplash.com/photos/{id}.

Update your next.config.js to use the domain source.unsplash.com instead of images.unsplash.com, and then use http://source.unsplash.com/{id} in your src attribute. The image should then render as expected.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cendenta