master

laravel/framework

Last updated at: 29/12/2023 09:24

FrameGuard.php

TLDR

This file contains the FrameGuard class, which is a middleware that adds the 'X-Frame-Options' header to the response with the value 'SAMEORIGIN'.

Classes

FrameGuard

The FrameGuard class is a middleware that handles the given request and sets the 'X-Frame-Options' header of the response to 'SAMEORIGIN'. It has a single method:

handle

This method takes in a request and a closure as parameters, and returns a response. It sets the 'X-Frame-Options' header of the response to 'SAMEORIGIN'.

<?php

namespace Illuminate\Http\Middleware;

use Closure;

class FrameGuard
{
    /**
     * Handle the given request and get the response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function handle($request, Closure $next)
    {
        $response = $next($request);

        $response->headers->set('X-Frame-Options', 'SAMEORIGIN', false);

        return $response;
    }
}