Re: Magento 2 - Can't display frontend in iframe

Hello !

 

I found a solution :

 

1 - Remove the x-frame-options from the env.php

2 - Override the \Magento\Framework\App\Response\HeaderProvider\XFrameOptions.php file ( don't forget the di.xml ) and comment the content of the __construct

class XFrameOptions extends \Magento\Framework\App\Response\HeaderProvider\XFrameOptions
{
    /** Deployment config key for frontend x-frame-options header value */
    const DEPLOYMENT_CONFIG_X_FRAME_OPT = 'x-frame-options';

    /** Always send SAMEORIGIN in backend x-frame-options header */
    const BACKEND_X_FRAME_OPT = 'SAMEORIGIN';

    /**
     * x-frame-options Header name
     *
     * @var string
     */
    protected $headerName = Http::HEADER_X_FRAME_OPT;

    /**
     * x-frame-options header value
     *
     * @var string
     */
    protected $headerValue;

    /**
     * @param string $xFrameOpt
     */
    public function __construct($xFrameOpt = 'SAMEORIGIN')
    {
        //$this->headerValue = $xFrameOpt;
    }
}

I don't know if it's the best way to do it but it works ^^ 

View solution in original post