does regex work in next.config.js for image domains? Looks like giphy uses different numbers for its endpoints (e.g. media0.giphy.com, media2.giphy.com) but regex isn't working so I'm getting this error: hostname "media0.giphy.com" is not configured under images in your next.config.js
. If not, is there a good way to handle this?
next.config.js
:
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
images: {
dangerouslyAllowSVG: true,
domains: ["media\\d.giphy.com"],
},
};
CodePudding user response:
No, domains
don't regex. Use remotePatterns which support glob (similar to regex).
Similar to remotePatterns, the domains configuration can be used to provide a list of allowed hostnames for external images.
However, the domains configuration does not support wildcard pattern matching and it cannot restrict protocol, port, or pathname.
Note: We recommend using remotePatterns instead so you can restrict protocol and pathname.