Universal Viewer not working when viewing PDF because of SSL

Universal Viewer gives me the following error when trying to view PDFs.

pdf.combined.js:52795 Mixed Content: The page at 'https://myarchive.co.uk/s/mysite/page/welcome#?c=&m=&s=&cv=' was loaded over HTTPS, but requested an insecure resource 'http://myarchive.co.uk/files/original/20058be87963e73b92cf532bb9ba2393f4fe9025.pdf'. This request has been blocked; the content must be served over HTTPS.

This was happening with JPEG files as well, but I enabled an option in IIIF Server module options, “Force base of url (from)” and “Force base of url (to)” with http and https respectively. That fixed the problem for images but for some reason I don’t understand, that fix didn’t work for PDFs. If I look at the manifest that got generated by https://myarchive.co.uk/iiif/83/manifest, the URL for the PDF is wrong (using http instead of https, same as in the error message).

How could I solve this?

The reason for this is that the substitution in the configuration is explicitly not applied to items in the media sequence when generating the manifest, you can patch the module to get around this, but it seems that a better way is to override the base URI for the file store in local.config.php. This will change the result from originalUrl() method of MediaRepresentation.

'file_store' => ['local' => ['base_uri' => 'https://myarchive.co.uk/files']],

Still have no idea why http: was being returned in the first place, though.

[1] https://gist.github.com/amoe/d81cfe3b77d01128ce09ee23ac0533cf