【问题标题】:Invalid src prop ({REDACTED URL}) on 'next/image', hostname is not configured under images in your 'next.config.js'\'next/image\' 上的 src prop ({REDACTED URL}) 无效,您的 \'next.config.js\' 中的图像下未配置主机名
【发布时间】:2022-08-16 16:18:03
【问题描述】:

即使在 next.config.js 中正确配置了 cdn 域,我也开始收到此错误。

在搜索了几个小时没有答案后,所以我在下面发布答案以供将来参考。

    标签: next.js next-images


    【解决方案1】:

    我在这里找到它next-docs

    您所要做的就是将模块导出更改为文档中描述的异步函数。

    module.exports = async (phase, { defaultConfig }) => {
      /**
       * @type {import('next').NextConfig}
       */
      const nextConfig = {
        /* config options here */
        images: {
          domains: ['***your domains here***'],
        },
      };
    
      return nextConfig;
    };
    
    

    【讨论】:

      猜你喜欢
      • 2021-09-13
      • 2021-03-02
      • 2021-08-12
      • 2016-04-16
      • 1970-01-01
      • 2021-12-12
      • 2021-06-06
      • 2022-11-11
      • 2021-04-11
      相关资源
      最近更新 更多