7

I'm facing issues with images on our Next.js headless application. My problem is that I always get an image error about a pipeline processor. But only when I go relative over the rendering instance URL. The error itself is obviously a .Net one. But when I call the relative URL directly on CM or CD it works fine! So I guess the rewriting/forwarding is corrupted somehow?! What misconfiguration could that be?

[ArgumentException: value]
System.UriBuilder.set_Scheme(String value) +206
System.UriBuilder..ctor(String schemeName, String hostName) +223
Sitecore.Web.WebUtil.GetRequestUri(HttpContextBase context) +160 Sitecore.Pipelines.HttpRequest.OverrideDialogs.Process(PreprocessRequestArgs args) +41
   (Object , Object ) +14
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +1268
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists) +236
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
   Sitecore.Web.RequestEventsHandler.OnBeginRequest(HttpContextBase context) +166
   Sitecore.Nexus.Web.HttpModule.HttpApplication_BeginRequest(Object sender, EventArgs e) +121 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +223
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +220
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +94

2 Answers 2

6

The problem is that by default in the docker example the Sitecore.LoadBalancing.Enabled setting is set to true which gets the schema for this SPEAK processor from the HttpContext.Current.Request.Headers[Settings.LoadBalancingScheme] and for some reason it contains http,https value which is not a valid HTTP schema. To do a quick and dirty fix you can apply the following patch:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
    <sitecore>
        <pipelines>
            <preprocessRequest>
                <!-- FIX: fix if "http,https" is in the Settings.LoadBalancingScheme header -->
                <processor patch:before="processor[@type='Sitecore.Pipelines.HttpRequest.OverrideDialogs, Sitecore.Speak.Applications']" type="Feature.Pipelines.LoadBalancingSchemeFix, Feature" role:require="Standalone or ContentManagement or ContentDelivery" />
            </preprocessRequest>
        </pipelines>
    </sitecore>
</configuration>
using Sitecore.Configuration;
using Sitecore.Pipelines.PreprocessRequest;
using System.Web;

namespace Feature.Pipelines
{
    public class LoadBalancingSchemeFix : PreprocessRequestProcessor
    {
        public override void Process(PreprocessRequestArgs args)
        {
            var scheme = HttpContext.Current?.Request?.Headers?[Settings.LoadBalancingScheme];
            if (Settings.LoadBalancingEnabled && (scheme?.Contains(",") ?? false))
            {
                HttpContext.Current.Request.Headers[Settings.LoadBalancingScheme] = scheme.Split(',')[0];
            }
        }
    }
}

Although this fix works, a Sitecore Support tickets needs to be raised. Once you get the Sitecore patch ID please post it 😊

1
  • Is there are Sitecore ticket number for this issue?
    – Anton
    Commented Aug 17, 2022 at 13:35
0

I submitted this issue to Sitecore. They've opened a feature request to support for multiple protocols in load balancing scheme header. In the meantime, they recommend using the accepted answer above (which worked for me also).

To track the future status of this bug report, please use reference number 529007. More information about public reference numbers can be found here: https://support.sitecore.com/kb?id=kb_article_view&sysparm_article=KB0853187

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.