I have trouble with written route for middleware. Nothing work there. I still can see page if use another IP My task - white list. When I visited my resource with not access IP it will route on another page. I use middleware
<?php
namespace App\Http\Middleware;
use Closure;
class FilterIps
{
const ALLOWED = [
'1.1.1.1',
];
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
abort_unless(in_array($request->ip(), self::ALLOWED), 403);
return $next($request);
}
}
Add to kernel file:
protected $middlewareGroups = [
'web' => [
FilterIps::class,
],
];
My route in web. Maybe he not correct? Or maybe I have not correct solution way for my task?
Route::group(['middleware' => 'web'], function () {
Route::get('/demo/loginjs', function () {
return view('auth.login');
});
});