【问题标题】:Images in Strapi media library not showingStrapi 媒体库中的图像未显示
【发布时间】:2023-01-15 03:38:01
【问题描述】:

我刚刚将我的 strapi cms 部署到 heroku,问题是当我将资产添加到媒体库时,图像将在几分钟后不显示,it looks like this

图片的 URL 存在于 API 上,但是当我手动检查它时,它显示“未找到”消息。这种情况有什么解决办法吗?

【问题讨论】:

  • 请阐明您的具体问题或提供更多详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: content-management-system strapi


【解决方案1】:

这个问题可能会得到解决。根据@strapi/provider-upload-cloudinary documentation

据此,我们需要将以下代码添加到./config/middlewares.js 文件中。

module.exports = [
  // ...
  {
    name: 'strapi::security',
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          'connect-src': ["'self'", 'https:'],
          'img-src': ["'self'", 'data:', 'blob:', 'dl.airtable.com', 'res.cloudinary.com'],
          'media-src': ["'self'", 'data:', 'blob:', 'dl.airtable.com', 'res.cloudinary.com'],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
  // ...
];

这应该可以解决问题,我们应该能够在 Strapi 媒体库中看到图像缩略图。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-12
    • 1970-01-01
    • 1970-01-01
    • 2015-05-07
    • 2017-07-08
    • 2022-12-30
    • 2022-06-20
    • 1970-01-01
    相关资源
    最近更新 更多