Next.js Discord

Discord Forum

Resolving "un-configured host", v15.2.4

Unanswered
kasz posted this in #help-forum
Open in Discord
Need to add a remote pattern in next.config.ts

6 Replies

I tried doing this:
import type { NextConfig } from "next";
import { RemotePattern } from "next/dist/shared/lib/image-config";

const nextConfig: NextConfig = {
  images: {
    remotePatterns: [new URL('https://i.postimg.cc/') as RemotePattern],
  }
};

export default nextConfig;
But it's getting an invalid protocol, it parses https: but the RemotePattern only accepts http/https
I logged the URL instance before it jumps to the error
Does the RemotePattern class have a faulty pattern matcher? Or am I doing something wrong
@kasz I logged the URL instance before it jumps to the error
Enlarged
Tentative solution:
const nextConfig: NextConfig = {
  images: {
    remotePatterns: [
      // new URL('https://i.postimg.cc/') as RemotePattern,
      {
        protocol: "https",
        hostname: "i.postimg.cc",
        pathname: "/**"
      }
    ],
  }
};