A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

Change meta title in CMS depending of environment CMS12 and CMS11

Vote:
 

Hi everyone and happy new year!

I am trying to alter meta title while using CMS in order to make it clear what environment the editor/admin is using, thus minimizing changes made in wrong environment.

For example, concatinating "Optimizely CMS - Edit" with the environment name; e g "PRODUCTION - Optimizely CMS - Edit" or "INTEGRATION - Optimizely CMS - Edit" or even "DEVELOPMENT- Optimizely CMS - Edit".

For this one could suggest using environment variable ASPNETCORE_ENVIRONMENT

For the actual site I ave a quite clear idea how to do this on the actual site, already.

 

And optionally also a similar solution for CMS 11

#341379
Jan 08, 2026 10:02
Vote:
 

Could be done using a middleware.

For CMS 12

var env = app.Environment.EnvironmentName;

app.Use(async (context, next) =>
{
    var originalBody = context.Response.Body;

    using var memStream = new MemoryStream();
    context.Response.Body = memStream;

    await next();

    context.Response.Body = originalBody;
    memStream.Seek(0, SeekOrigin.Begin);

    if (context.Response.ContentType?.Contains("text/html") == true)
    {
        var html = await new StreamReader(memStream).ReadToEndAsync();

        html = html.Replace(
            "<title>",
            $"<title>[{env}] "
        );

        await context.Response.WriteAsync(html);
    }
    else
    {
        await memStream.CopyToAsync(originalBody);
    }
});

To have this working for CMS 11 / .NET Framework you'd have to add an IHttpModule. I think I've made one in the past, want me to post that as well?

#341381
Edited, Jan 08, 2026 11:47
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.