Is there a way to block Sitecore from creating the {website}#lang cookie? When Sitecore's Layout Service is used with a headless app (a next js app)?

Will it be enough to add a processor in getLayoutServiceContext, that inherits JssGetLayoutServiceContextProcessor, that will remove the lang cookie? So that Layout Service will not send over the lang cookie to the next js app, that will sequentially set it up to the visitor's browser.

1 Answer 1


Here is an example of how you can create a custom processor to remove the lang cookie for Layout Service requests:

Create a new class that inherits from JssGetLayoutServiceContextProcessor. Override the Process method and remove the lang cookie from the response object. Register your custom processor in the httpRequestBegin pipeline after the JssGetLayoutServiceContextProcessor processor. Here is an example of what the code for the custom processor might look like:

using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Sitecore.JavaScriptServices.Configuration;
using Sitecore.JavaScriptServices.Core;
using Sitecore.JavaScriptServices.ViewEngine.LayoutService.Pipelines.GetLayoutServiceContext;

namespace MyCustom.Processors
    public class RemoveLangCookieProcessor : JssGetLayoutServiceContextProcessor
        public override void Process(GetLayoutServiceContextArgs args)

            var httpContext = args.Context.RequestServices.GetService<IHttpContextAccessor>().HttpContext;

Remember to register your custom processor in the httpRequestBegin pipeline after the JssGetLayoutServiceContextProcessor processor:

    <processor type="Sitecore.JavaScriptServices.ViewEngine.LayoutService.Pipelines.Services.GetLayoutServiceContext.JssGetLayoutServiceContextProcessor, Sitecore.JavaScriptServices.ViewEngine"/>
    <processor type="MyCustom.Processors.RemoveLangCookieProcessor, MyCustom"/>

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.