如何设置下一个配置以从 http 和 https 协议获取图像
`/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
protocol: "https" || "http",
hostname: "**",
port: "",
pathname: "/**",
},
],
},
};
export default nextConfig;`
但是http好像不起作用
那是因为使用
||
检查一个或多个表达式是否为 true,因为 "https"
被转换为 true,它完全忽略第二个字符串 "http"
,你可以这样做:
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: "**",
port: "",
pathname: "/**",
},
{
protocol: "http",
hostname: "**",
port: "",
pathname: "/**",
},
],
},
};
export default nextConfig;