jestjs - 使用 NEXT/IMAGE 开玩笑时出错:`next/image` 上的 src 属性无效,主机名“res.cloudinary.com”未在`next.config.js` 中的图像下配置
问题描述
我用 img 做了一些测试,它非常好,但是当我添加下一个/图像时,会生成这个错误,即使配置了 next.config.js 文件,错误仍然存在。
Invalid src prop (https://res.cloudinary.com/dezwlfeyb/image/upload/v1635633843/Contabilidade-Smart-negativo-172_e5oyxn.png) on `next/image`, hostname "res.cloudinary.com" is not configured under images in your `next.config.js`
See more info: https://nextjs.org/docs/messages/next-image-unconfigured-host
10 | ui: ReactElement,
11 | { ...renderOptions }: CustomRenderProps = {}
> 12 | ) => render(<ThemeProvider theme={theme}>{ui}</ThemeProvider>, renderOptions)
next.config.js
// eslint-disable-next-line @typescript-eslint/no-var-requires
const withPWA = require('next-pwa')
const isProd = process.env.NODE_ENV === 'production'
module.exports = withPWA({
pwa: {
dest: 'public',
disable: !isProd
},
images: {
domains: ['localhost', 'res.cloudinary.com']
}
})
解决方案
推荐阅读
- php - 我在这一行找不到错误
- python - Django 查询集过滤器 - 为什么满足过滤器中所有条件的对象未包含在结果集中?
- javascript - Node.js、Mongodb 和 MongoClient 本地 - 可能有多少个连接?“关闭套接字时出错”
- python - pine 脚本如何使用 2 个系列而不是 1 个和一个句点来计算 RSI?
- java - 返回数组类
- python - Django:显示模型字段中的图像?
- three.js - three.js obj + mtl 不起作用
- javascript - 通过 jquery 的表格编辑器
- apache-spark - Windows 上的 Pyspark:WARN 无法加载 NativeSystemBLAS 和 NativeRefBLAS
- php - 如何为所有 php 页面定义一个变量?