Search code examples
phprouteslaravel-5middlewareelfinder

Laravel 5.2 Middleware in elfinder


when the middleware is added to the elfinder I confronted with this error, but when I amount equal to the null set thhis problem fixed.

'route' => [
    'prefix' => 'elfinder',
    'middleware' => null, //Set to null to disable middleware filter
],

config/elfinder.php:

'route' => [
    'prefix' => 'elfinder',
    'middleware' => ['web','auth'], //Set to null to disable middleware filter
],

my problem is:

enter image description here


Solution

  • this problem solve by under code to app/Http/Middleware/VerifyCsrfToken.php

    <?php
    
    namespace App\Http\Middleware;
    use Closure;
    use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
    
    class VerifyCsrfToken extends BaseVerifier
    {
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'elfinder/ckeditor',
    ];
    public function handle($request, Closure $next)
    {
        $regex = '#' . implode('|', $this->except) . '#';
    
        if ($this->isReading($request) || $this->tokensMatch($request) || preg_match($regex, $request->path()))
        {
            return $this->addCookieToResponse($request, $next($request));
        }
    
        throw new TokenMismatchException;
    }
    }