mardi 30 mai 2017

Laravel auth middleware not working to download jpeg

First, it happens only in production, I'm using Cloudways with laravel stack (debian + nginx + apache + mysql).

In my local environment, everything works fine.

Every time I try to open the URL with the right parameters I got redirected to home/login, like if the middlewere had rejected.

The URL was supposed to download my image.

Routes/web.php:

Route::get('image/{name}', 'FileController@getImage');

Controller/FileController.php:

class FileController extends Controller {
    public function __construct()
    {
        // if I comment this line, it works in production too, but I can download content without being logged in... 
        $this->middleware('auth');
    }

    public function getImage($name)
    {
        return response()->download(storage_path('app/images/' . $name), null, [], null);
    }
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2rC1yGz
via IFTTT

Aucun commentaire:

Enregistrer un commentaire