Preview uses piwikUrl and doesnt seem overridable

Testing preview uses piwikUrl from database to reference the domain for hosting container_CONTAINERID_preview.js.
In my case this is http(s)://10.244.24.61/js/container_CONTAINER_preview.js and not http(s)://analytics.example.com/js/container_CONTAINER_preview.js

piwikUrl is updated by core:archive and visits to matomo dashboard on https://matomo-dash.example.com and they race about updating this field in the db.

Hi @roflmao
What happens in the network (while using the production container AND also the preview one)?
How is configured the MTM bootstrap code: with 10.244.24.61, or with analytics.example.com?

It seems it is automatically configured via matomo’s piwikUrl from the database which is automatically set by matomo upon visiting the site and same with running core:archive. Visiting the page gives piwikUrl set to analytics.example.com and running the archive updates it do the ip of the container running the core:archive.

Can i set the domain for preview as a variable in Matomo Tag Manager to override?

Hi @roflmao
Very strange behavior…
Does problem occur only in preview mode?
To which address do you configure MTM container (10.244.24.61 , or with analytics.example.com)?

Only preview which gives container_ID.js with content:

(function() {
    var b = document;
    var a = window;
    if ((document.cookie.indexOf('mtmPreview1_FDVOG8VX%3D1') !== -1 && window.location.href.indexOf('&mtmPreviewMode=0') === -1 && window.location.href.indexOf('?mtmPreviewMode=0') === -1) || window.location.href.indexOf('&mtmPreviewMode=FDVOG8VX') !== -1 || window.location.href.indexOf('?mtmPreviewMode=FDVOG8VX') !== -1) {

        var d = document
          , g = d.createElement('script')
          , s = d.getElementsByTagName('script')[0];
        g.type = 'text/javascript';
        g.async = false;
        g.defer = false;
        g.src = 'https://10.244.20.12/js/container_FDVOG8VX_preview.js';
        s.parentNode.insertBefore(g, s);
        return;
    }

The MTM is hosted on analytics.example.com/js/container_FDVOG8VX.js

The problem here is g.src is set to a seperate host, not keeping the domain as regular MTM does without preview.

Hi @roflmao
Can you confirm the Matomo version?
This behavior is very strange. Could @innocraft explain this in depth?

This is Matomo 4.15.1