How to add, replace or remove Middleware

This is a community-contributed tutorial. This tutorial is over a year old and may not apply to your version of Concrete CMS.
Oct 4, 2019
By hissy for Developers

HTTP middlewares are configured in concrete/config/app.php

    'middleware' => [
            'priority' => 1,
            'class' => \Concrete\Core\Http\Middleware\ApplicationMiddleware::class,
        'core_cookie' => \Concrete\Core\Http\Middleware\CookieMiddleware::class,
        'core_xframeoptions' => \Concrete\Core\Http\Middleware\FrameOptionsMiddleware::class,
        'core_thumbnails' => '\Concrete\Core\Http\Middleware\ThumbnailMiddleware',

You can add your own middleware by overriding config value from application/config/app.php. Of course, you can change the class too.

return [
    'middleware' => [
        'core_cookie' => \Application\Concrete\Http\Middleware\MyCustomizedCookieMiddleware::class,
        'my_great_middleware' => \Application\Concrete\Http\Middleware\MyGreatMiddleware::class,

If you want to remove a core middleware, you need to create a passthru middleware.

return [
    'middleware' => [
        'core_xframeoptions' => \Application\Concrete\Http\Middleware\PassThruMiddleware::class,
namespace Application\Concrete\Http\Middleware;

use Concrete\Core\Http\Middleware\DelegateInterface;
use Concrete\Core\Http\Middleware\MiddlewareInterface;
use Symfony\Component\HttpFoundation\Request;

class PassThruMiddleware implements MiddlewareInterface
     * {@inheritdoc}
    public function process(Request $request, DelegateInterface $frame)
        // PassThru
        return $frame->next($request);
Recent Tutorials
Upgrading Concrete from 8.5 to 9.x
Jun 21, 2024
By myq.

How to avoid problems upgrading from 8.5 to 9.x

How to change the default date format
May 30, 2024
By myq.

Change the format of the default date

WebOps Tutorial on Running and Upgrading a Concrete CMS Website
May 2, 2024
By myq.

Describes how to deploy, manage, and upgrade a Concrete CMS website

Using the Concrete Migration Tool Addon
Apr 27, 2024

How to use the Concrete CMS Migration Tool

Create custom Site Health tasks
Apr 19, 2024
By myq.

This tutorial will guide you through the creation of a new Site Health task

Reusing the same Express entity in multiple associations
Apr 11, 2024
By myq.

How to create and manage multiple associations in Express


Let us know by posting here.