Sitecore Commerce 10.2 adventures – Node Headless SSR Proxy, make it purr like a kitten

Dear fellow Sitecorians! Today’s post will be a short one  🙂

Earlier this year, we upgraded from10.0 to 10.2. Today I want to share my findings(and pain) regarding Sitecore Dictionaries in Node Headless SSR Proxy.

We have several Node Headless SSR Proxies, using the excellent sample code from Sitecore – node/express scaffolding for SSR outside of Sitecore Content Delivery Together with our fix – Running Sitecore JSS with Node Headless SSR Proxy in Sitecore 10, all in Docker – This is the Way

We upgraded the Node Headless SSR Proxy according to Sitecore’s sample. We also upgraded our JSS ( sorry, I mean Headless 😉  ) apps according to the Sitecore JSS React Starter Application

It worked well when running it locally, using the command:

jss start:connected

But when running in Node Headless SSR Proxy, we almost got it to work except for the dictionaries URL:
https://mysite.localhost/sitecore/api/jss/dictionary/MySite/sv-SE?sc_apikey={xxxyyyyxxxxxyyyyy}

It gave 500, and when looking in the logs on CD we see this error:

URL http://mysite.localhost/sitecore/api/jss/dictionary/MySite/sv-SE?sc_apikey={xxxyyyyxxxxxyyyyy}


Exception System.UriFormatException: Invalid URI: The URI scheme is not valid.

   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)

   at Sitecore.Services.Infrastructure.OData.XForwardDelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)

   at System.Net.Http.DelegatingHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)

   at Sitecore.Services.Infrastructure.Security.TokenDelegatingHandler.<SendAsync>d__6.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

   at System.Web.Http.HttpServer.<SendAsync>d__24.MoveNext()

After a closer investigation, it turns out to be one of the delegating handlers in the Sitecore.Services.Client.config. This part:

<delegatingHandlers hint="list:AddDelegatingHandler">
	<delegatingHandler desc="TokenDelegatingHandler">Sitecore.Services.Infrastructure.Sitecore.Security.TokenDelegatingHandler, Sitecore.Services.Infrastructure.Sitecore</delegatingHandler>
	<delegatingHandler desc="XForwardDelegatingHandler">Sitecore.Services.Infrastructure.OData.XForwardDelegatingHandler, Sitecore.Services.Infrastructure</delegatingHandler>
</delegatingHandlers>

To verify if that is the case, I removed the XForwardDelegatingHandler:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"  xmlns:set="http://www.sitecore.net/xmlconfig/set/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
    <sitecore role:require="ContentDelivery">
        <api>
            <services>
                <configuration type="Sitecore.Services.Infrastructure.Configuration.ServicesConfiguration, Sitecore.Services.Infrastructure">
                    <delegatingHandlers hint="list:AddDelegatingHandler">
                         <delegatingHandler desc="XForwardDelegatingHandler">
                            <patch:delete />
                        </delegatingHandler>
                    </delegatingHandlers>

                </configuration>
            </services>
        </api>

    </sitecore>
</configuration>

And success, the Node Headless SSR Proxy worked and purred like a kitten 🙂

What is left is to figure out why we got this error and to see how we can fix it without removing the XForwardDelegatingHandler. But that’s for another day…

That’s all for now folks 😊


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.