expectsJson() || $request->wantsJson()) { return $next($request); } $response = $next($request); if (!str_starts_with($request->url(), url('/forms/'))) { if ($response instanceof Response) { $response->header('X-Frame-Options', 'SAMEORIGIN'); } elseif ($response instanceof \Symfony\Component\HttpFoundation\Response) { $response->headers->set('X-Frame-Options', 'SAMEORIGIN'); } } return $response; } }