System Information
- Strapi Version: 4.1.7
- Operating System: MacOS (Local) / Ubuntu 18.04 (deployment)
- Database: Postgres
- Node Version: 14.19.1
- NPM Version: 6.14.16
- Yarn Version: 1.22.17
- strapi-provider-upload-dos: ^4.0.5
Hi Strapi community!
I have been using Strapi since v3, recently switched to Strapi v4 for another production level application to support backend infrastructure. I have been facing an issue for a long time, and have looked into all the places for a solution for it.
Issue
When uploading an image file to Media Library which I have integrated with DOSpaces CDN, image previews are broken.
I’ve tried editing Security Policies as suggested in many GitHub issues and posts on this forum as follows:
// ./config/middlewares.js
const MEDIA_URL = process.env.DO_SPACE_CDN; // CDN URL appended with "https://"
console.log(`MEDIA_URL: ${MEDIA_URL}`);
module.exports = [
"strapi::errors",
{
name: "strapi::security",
config: {
useDefaults: true,
contentSecurityPolicy: {
directives: {
"connect-src": ["'self'", "https:"],
"img-src": ["'self'", "data:", "blob:", MEDIA_URL],
"media-src": ["'self'", "data:", "blob:", MEDIA_URL],
upgradeInsecureRequests: null,
},
},
},
},
"strapi::cors",
"strapi::poweredBy",
"strapi::logger",
"strapi::query",
"strapi::body",
"strapi::session",
"strapi::favicon",
"strapi::public",
];
Looking for help
What am I doing wrong here? Am I missing something? Is this an issue with v4 of Strapi? because in v3 everything was working perfectly fine. I am willing to be active and help you with investigating on this, please help.