[英]using regex for image domains in NextJS next.config.js
does regex work in next.config.js for image domains?正则表达式在 next.config.js 中是否适用于图像域? Looks like giphy uses different numbers for its endpoints (eg 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
.看起来 giphy 为其端点使用了不同的数字(例如 media0.giphy.com、media2.giphy.com),但正则表达式不起作用,所以我收到此错误:
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
: next.config.js
:
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
images: {
dangerouslyAllowSVG: true,
domains: ["media\\d.giphy.com"],
},
};
No, domains
don't support regex.不,
domains
不支持正则表达式。 Use remotePatterns which support glob (similar to regex).使用支持 glob 的remotePatterns (类似于正则表达式)。
Similar to remotePatterns, the domains configuration can be used to provide a list of allowed hostnames for external images.
与 remotePatterns 类似,域配置可用于为外部图像提供允许的主机名列表。
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.
注意:我们建议改用 remotePatterns,这样您就可以限制协议和路径名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.