diff --git a/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php b/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php index f8ac005a5827..0f24357e20fc 100644 --- a/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php +++ b/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php @@ -5,6 +5,7 @@ use Closure; use Illuminate\Contracts\Encryption\Encrypter; use Illuminate\Contracts\Foundation\Application; +use Illuminate\Contracts\Support\Responsable; use Illuminate\Cookie\Middleware\EncryptCookies; use Illuminate\Session\TokenMismatchException; use Illuminate\Support\InteractsWithTime; @@ -177,6 +178,10 @@ protected function addCookieToResponse($request, $response) { $config = config('session'); + if ($response instanceof Responsable) { + $response = $response->toResponse($request); + } + $response->headers->setCookie( new Cookie( 'XSRF-TOKEN', $request->session()->token(), $this->availableAt(60 * $config['lifetime']),