You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Next.js next/image组件报错:image.tmdb.org未配置,配置后仍无效

解决Next.js next/image 主机名未配置问题

问题原因

你配置的pathname过于严格,仅匹配/t/p/original路径,但TMDB图片存在多种尺寸路径(如/t/p/w500、/t/p/w300等),导致部分图片路径无法匹配规则,触发报错。

修复步骤

  1. 修改next.config.js的remotePatterns配置
    将pathname改为通配格式,覆盖所有TMDB图片路径:

    const nextConfig = {
      images: {
        remotePatterns: [
          {
            protocol: 'https',
            hostname: 'image.tmdb.org',
            port: '',
            pathname: '/t/p/**', // 用通配符匹配所有图片路径
          },
        ],
      },
    };
    
    module.exports = nextConfig;
    
  2. 重启Next.js开发服务器
    修改next.config.js后必须重启服务,新配置才会生效。

  3. 验证图片src格式
    确保next/image的src是完整的HTTPS链接,例如:https://image.tmdb.org/t/p/original/your-image-id.jpg,不能使用相对路径。

内容的提问来源于stack exchange,提问作者bhuws

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 05:04:54