Files
ntspi-app/app/Ship/Middleware/InternalRequestOnly.php
T
F4ilji c01016a154 Migrate backend to Porto architecture and fix minor bugs
- Fully transitioned the backend to the Porto architectural pattern
- Improved code organization and maintainability
- Fixed minor bugs and inconsistencies
2025-05-12 08:47:43 +05:00

28 lines
814 B
PHP

<?php
namespace App\Ship\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class InternalRequestOnly
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next)
{
$userAgent = $request->header('User-Agent');
// Проверяем, что User-Agent содержит ключевые слова, характерные для браузеров
if (!preg_match('/Mozilla|Chrome|Safari|Firefox|Edge/i', $userAgent)) {
return response('Access denied. This route is available only from a web browser.', 403);
}
return $next($request);
}
}