Getting wrong Google Cloud Storage path in Strapi v4

The issue already solved!

The way to solve that issue is

  1. Cause the env is production mode, in Strapi v4, you should create everything files into config/env/production
  2. Create file plugins.js, fill it like this.
const fs = require('fs');
require('dotenv').config();

module.exports = ({ env }) => ({
  upload: {
    config: {
      provider: 'strapi-provider-upload-google-cloud-storage',
      providerOptions: {
        serviceAccount: JSON.parse(fs.readFileSync(process.env.GCS_SERVICE_ACCOUNT)),
        bucketName: env('GCS_BUCKET_NAME'),
        basePath: env('GCS_BASE_PATH'),
        baseUrl: env('GCS_BASE_URL'),
        publicFiles: true,
        uniform: false,
        gzip: true,
      },
    },
  },
});

The key is publicFiles, because if value is false it doesn't create public url in Google Cloud Storage and we cannot get and see the image

  1. Addition notes, don't forget to add security in order to get permission from GCS (Google Cloud Storage)
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',
  'strapi::poweredBy',
  'strapi::logger',
  'strapi::query',
  'strapi::body',
  'strapi::favicon',
  'strapi::public',
];