I tried this a while back but got nowhere:
{
name: 'updateVideoUrls',
config: {},
path: '/content-manager/single-types/*',
},
'strapi::logger',
'strapi::errors',
....
];
// middleware/update-video-urls.js
module.exports = async (ctx, next) => {
if (ctx.request.route.path.startsWith('/content-manager/single-types') && ctx.request.method === 'PUT') {
const { result } = ctx.request.body;
if (result && result.video && result.video.length > 0) {
result.video = result.video.map((videoData) => {
const originalUrl = videoData.url;
const cloudFrontUrl = originalUrl.replace('[S3 BUCKET URL]', '[CLOUDFRONT URL]');
videoData.url = cloudFrontUrl;
return videoData;
});
}
}
await next();
};