API route URI registered using the GET method and the callback function from a particular Controller and it returns a 404 view
API route was grouped inside a prefix and tried to manually attach the API onto the URI, but when I use a post method it works just fine.
Route.php
Route::group(['prefix' => '/api'], function() {
Route::get('/avatar/{avatar}', 'AvatarController@avatar');
});
AvatarController.php
public function avatar($avatar) {
$path = storage_path('app/avatars/' . $avatar);
if (!File::exists($path)) {
abort(404);
}
$file = File::get($path);
$type = File::mimeType($path);
$response = Response::make($file, 200);
$response->header("Content-Type", $type);
return $response;
}
Image file