【问题标题】:next/image Un-configured Host with IP domain [duplicate]下一个/图像具有 IP 域的未配置主机 [重复]
【发布时间】:2022-01-04 18:32:06
【问题描述】:

我使用 NextJS 构建站点,图像托管在其他使用 IP 运行的开发服务器上。该文件可通过图像路径公开访问: http://xxx.xx.xxx.xxx:8080/storage/user-profile/61d41e2b05de9_WhatsApp%20Image%202022-01-02%20at%2021.46.03.jpeg 但我收到以下错误: Error Message

我在 next.config.js 中添加了以下代码:

module.exports = {
  images: {
    domains: ["http://xxx.xx.xxx.xxx:8080"],
  },
};

甚至尝试过

module.exports = {
  images: {
    domains: ["http://xxx.xx.xxx.xxx:8080"],
  },
};

两者都返回如上截图所示的相同错误

非常感谢任何帮助

【问题讨论】:

    标签: next.js nextjs-image


    【解决方案1】:

    域不应包含 http://https:// 或包含的方案

    您可以使用源图片网址的主机名

    module.exports = {
      images: {
        domains: ['cdn.yoursite.com'],
      },
    }
    

    【讨论】:

    • 感谢杰森。删除 http 和 https 解决了问题
    猜你喜欢
    • 2021-12-12
    • 2013-07-04
    • 1970-01-01
    • 2020-04-19
    • 1970-01-01
    • 2018-06-11
    • 2010-10-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多