Theo's Typesafe CultTTC
Theo's Typesafe Cult4y ago
6 replies
rustclan

Nextjs hostname is not configured under images in next.config.js

Hey

I am getting the following error when trying to display a discord image on my website through their cdn
on `next/image`, hostname "cdn.discordapp.com" is not configured under images in your `next.config.js`

I have added the domains into the defineNextConfig inside of next.config.mjs but I still get the same error.

// @ts-check
import { env } from "./src/env/server.mjs";

/**
 * Don't be scared of the generics here.
 * All they do is to give us autocompletion when using this.
 *
 * @template {import('next').NextConfig} T
 * @param {T} config - A generic parameter that flows through to the return type
 * @constraint {{import('next').NextConfig}}
 */
function defineNextConfig(config) {
  return config;
}

export default defineNextConfig({
  reactStrictMode: true,
  swcMinify: true,
  // Next.js i18n docs: https://nextjs.org/docs/advanced-features/i18n-routing
  i18n: {
    locales: ["en"],
    defaultLocale: "en",
  },
  images: {
    domains: ["avatars.githubusercontent.com", "cdn.discordapp.com", "lh3.googleusercontent.com"],
  },
});

Any clue what's wrong?
Was this page helpful?