Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thumbnails not showing in Media Library #166

Closed
ianyoung opened this issue Apr 3, 2023 · 1 comment
Closed

Thumbnails not showing in Media Library #166

ianyoung opened this issue Apr 3, 2023 · 1 comment

Comments

@ianyoung
Copy link

ianyoung commented Apr 3, 2023

After setting up the bucket, service account, and adding the plugins.js configuration along with middlewares.js configuration, images upload to GCS successfully but the thumbnail is never shown in the Media Library.

plugins.js

module.exports = ({ env }) => ({
    upload: {
      config: {
        provider: "@strapi-community/strapi-provider-upload-google-cloud-storage",
        providerOptions: {
          serviceAccount: env.json("GCS_SERVICE_ACCOUNT"),
          bucketName: env("GCS_BUCKET_NAME"),
          baseUrl: env("GCS_BASE_URL"),
          basePath: "",
          publicFiles: true,
          uniform: false,
        },
      },
    },
  });

middlewares.js

module.exports = [
  "strapi::errors",
  {
    name: "strapi::security",
    config: {
      contentSecurityPolicy: {
        useDefaults: true,
        directives: {
          "connect-src": ["'self'", "https:"],
          "img-src": ["'self'", "data:", "blob:", "storage.googleapis.com"],
          "media-src": ["'self'", "data:", "blob:", "storage.googleapis.com"],
          upgradeInsecureRequests: null,
        },
      },
    },
  },
  "strapi::security",
  "strapi::cors",
  "strapi::poweredBy",
  "strapi::logger",
  "strapi::query",
  "strapi::body",
  "strapi::session",
  "strapi::favicon",
  "strapi::public",
];

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Media Library'
  2. Click on 'Add new assets'
  3. Drag and drop new image.
  4. Click on 'Upload new asset'
  5. Results in broken thumbnail (below)

If I view the image from Cloud Storage however it does display fine in the browser.

As a side note, using the above settings also sees a size folder created for each image upload as discussed in #150

The bucket has been created with Fine-grained access controls as per the guidelines.

Is there something else I need to do to be able to view the thumbnails?

Strapi version: 4.9.0
Plugin version: 4.6.1

@ianyoung
Copy link
Author

ianyoung commented Apr 3, 2023

Solved. The problem was that I had strapi::security in twice. The second (empty) declaration was effectively overwriting whatever I was putting in the first.

@ianyoung ianyoung closed this as completed Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant