我有各种图像网址并随着时间的推移而变化(图像是通过网址地址获取的,而不是本地或来自私人存储)。为了渲染<Image />
tag 、域名应该传递给 nextjs 配置。
随着时间的推移,不可能传递数百个 url。
如何允许所有域?
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
domains: [
"img.etimg.com",
"assets.vogue.com",
"m.media-amazon.com",
"upload.wikimedia.org",
],
},
};
module.exports = nextConfig;
我尝试过这个但不起作用"*.com"
它对我有用,因此 next.js 文档:
const nextConfig = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: "**",
},
],
},
};
Next.js 配置选项 https://nextjs.org/docs/pages/api-reference/components/image#configuration-options
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)