How to link properly google cloud platform (buckets) to display images in strapi admin

  • Strapi 4.5.1
  • Debian 11:
  • Mysql 8.0:
  • 16.18.1:
  • npm 9.2:

I am trying to save my media in google cloud platform buckets (also deployed in a GCP vm). I am following the docs but i am still getting error.

This is my plugins.js

module.exports = {
    upload: {
      config: {
        provider: '@strapi-community/strapi-provider-upload-google-cloud-storage',
        providerOptions: {
            bucketName: 'bucketname',
            publicFiles: true,
            uniform: true,
            baseUrl: 'https://storage.googleapis.com/bucketname',
            basePath: '',
        },
      },
    },
}

Here is my 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::cors',
...

THANKS!

Hi @andercm have you tried adding https://storage.googleapis.com? Maybe this could work

1 Like

can you please check if you deleted the line ‘strapi::security’ from middlewares.js. (that was my noob mistake)

1 Like

Yes, I replaced the default ‘strapi::secuirity’ for this.
This how i have the middleware ( I tried adding https:…/bucket)

I know it’s a little bit late but, removing baseUrl from upload config in plugins.js will give you the correct url, also publicFiles should be false

hi @andercm
did you solve it? thanks