1

After upgrading to Laravel 5.5, this code:

    $headers = ['Content-Type: ' . $fileData[2]];
    return Response::download($fileData[0], $fileData[1] ,$headers);

generates this error:

Call to undefined method Symfony\Component\HttpFoundation\BinaryFileResponse::withCookie()

in CreateFreshApiToken.php (line 51)
at CreateFreshApiToken->handle(object(Request), object(Closure))
in Pipeline.php (line 149)

Any idea? Might it be a bug? It worked well with Laravel 5.4.

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
Peter Matisko
  • 2,113
  • 1
  • 24
  • 47

1 Answers1

1

You should verify what CreateFreshApiToken.php does. Response::download is returning Symfony\Component\HttpFoundation\BinaryFileResponse and this class doesn't have withCookie method. In Laravel 5.4 it seems it was exactly the same. If it won't help include this class code and what middleware are you using in App\Http\Kernel.php file.

It seems something was broken in Laravel Passport in this PR http://github.com/laravel/passport/pull/474 . You can also look at http://github.com/laravel/passport/issues/489 and maybe remove this route from web middleware if it's possible as a temporary fix and wait for making fix in Laravel Passport

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
  • CreateFreshApiToken.php comes from Passport: vendor\laravel\passport\src\Http\Middleware\CreateFreshApiToken.php. There is this line, before withCookie is called: if($this->shouldReceiveFreshToken($request, $response)) – Peter Matisko Sep 07 '17 at 19:50
  • @PeterMatisko Are yo using latest Passport release (4.0.2) ? – Marcin Nabiałek Sep 07 '17 at 19:54
  • @PeterMatisko It seems something was broken in https://github.com/laravel/passport/pull/474 . You can also look at https://github.com/laravel/passport/issues/489 and maybe remove this route from `web` middleware if it's possible as a temporary fix – Marcin Nabiałek Sep 07 '17 at 20:00
  • I am doing some reverse engineering in the passport functions. Seems like "cookies" in $response is empty. – Peter Matisko Sep 07 '17 at 20:00