Trouble with Programmatically Updating Media URLS in API to Cloudfront domain URL

So if you wanna mod the url for fronted that’s way to go

I tried this a while back but got nowhere:

    name: 'updateVideoUrls',
    config: {},
    path: '/content-manager/single-types/*', 
// 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 && && > 0) { = => {
        const originalUrl = videoData.url;
        const cloudFrontUrl = originalUrl.replace('[S3 BUCKET URL]', '[CLOUDFRONT URL]');
        videoData.url = cloudFrontUrl;
        return videoData;

  await next();

I read about middleware and again just tried to just wing it

The code should be after await next()

It kept having a fit at me saying invalid middleware configuration and I couldnt quite debug it:

ill take a look

Also this not exactly your case but have descent description

cheers Ill have a read but I need to go cook some food first

<@146710533985402881> did you happen to get it working by any chance? sorry for necroing the thread