I'm trying to redirect any 404 errors from my image storage folder to an empty 404 error instead of the normal 404 template.
My images are through Glide and show up as:
http://example.com/img/http/aHR0cHM6Ly93d3cudmFuY291dmVyY29udmVudGlvbmNlbnRyZS5jb20vaW1hZ2VzL2xvZ28tZGZkMDdhNzM5Y2NhNmQ2NDVkY2Y0NDg5OWIyNTQ5NWEuanBn?fm=webp&s=fe55826dcb196df2ae0f2e4055e9dab9
So they don't register as missing images, but pages not found.
So in my handler I'm running this to see if I get an response but its not doing anything yet:
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use League\Glide\Filesystem\FileNotFoundException as GlideFileNotFoundException;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array<int, class-string<Throwable>>
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array<int, string>
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (Throwable $e) {
//
});
$this->renderable(function (NotFoundHttpException $e, $request) {
dump($request);
if ($request->is('img/http/*')) {
return response()->json([
'status' => 204,
'message' => 'Data not found'
], 200);
}
});
}
}
But this seems to do nothing. Any ideas what I'm missing? I'm using the 204/200 error just to see anything change. The end goal is to just have a blank 404 server error for images.