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);
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire