I think that this is a bug in Sitecore.
Here's whats happening
When you enable the CDN config, it sets Media.AlwaysAppendRevision to true
This appends rev=xxx to all media urls
The media request protection protectedMediaQueryParameters config has <parameter name="rev" description="media revision"/>.
The media request protection code in Sitecore....
First of all, you don't need to have a delegate there. It is useful when your function can accept optional parameters. You won't do it in Func and that is why we are using delegate.
Otherwise, you can do something like that and skip delegate:
args.GlobalScriptObject.Import("sc_link", new Func<Item, string>((item) =>
For me Sitecore.Sites.SiteContextFactory.Sites worked to get all sites.
If you need to know whether it is an SXA site or not, you can check for the property IsSxaSite (something like x => !string.IsNullOrEmpty(x.Properties.Get("IsSxaSite"))
I have answered the question you linked with some steps to troubleshoot this - but I will also answer here with an additional finding due to this question regarding SXA specifically.
I found an issue where forms embedded in overlays in SXA (versions 1.9 and 9.3) will have this issue due to this bug in the component-overlay.js of the components theme which ...
I don't think this can work out of the box. The search results component reacts on a signature. In order to match the results with the search box those signatures need to be empty or the same.
I stumbled across this while looking for a solution to the same issue and thanks to Mark's info I was able to get rid of the log spam by simply wrapping the GetMediaUrl in an extension method in which i'm foribly appending something that will be hashed with the media protection logic (so there will always be a hash value appended for places that I need it). ...
There are two ways to accomplish this, use custom Scriban extension, see the following code sample:
public class GetLinkUrl : IGenerateScribanContextProcessor
private readonly IContext context;
private delegate string LinkUrlDelegate(Item item, string linkFieldName);
public GetLinkUrl(IContext context)
this.context = context;