Next.js Discord

Discord Forum

next/image allow all domains

Unanswered
Siamese posted this in #help-forum
Open in Discord
Avatar
SiameseOP
Hi! How can I make so all domains will work?
/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  images: {
    domains: [],
  },
}

module.exports = nextConfig

6 Replies

Avatar
SupremeDeity
IIRC you can pass "**" to hostname. I might be wrong tho. Also do know that this is potentially unsafe, so dont do it unless you really have to. You can take a look at the link below of how you can use the ** in other ways which might be better.

[Docs reference](https://nextjs.org/docs/app/api-reference/components/image#remotepatterns)
Avatar
Ray
yes, it is not recommend to allow all hostname. because everyone can use your endpoint to do the image optimization. also if you are hosting on vercel you may get an unexpected bill
Image
Avatar
SiameseOP
Didn't know that, but I'm self hosting
I will only use pics from local directory, discord server logos, discord avatars and my cdn
Avatar
Ray
then it is better to add the domain of discord and your cdn
Avatar
SiameseOP
k