protected function response(Request $request, Closure $next)
    {
        // Shop is OK, now check if ESDK is enabled and this is not a JSON/AJAX request...
        $response = $next($request);
        if (
            Config::get('shopify-app.esdk_enabled') &&
            ($request->ajax() || $request->expectsJson() || $request->isJson()) === false
        ) {
            if (($response instanceof BaseResponse) === false) {
                // Not an instance of a Symfony response, override
                $response = new Response($response);
            }

            // Attempt to modify headers applicable to ESDK (does not work in all cases)
            $response->headers->set('P3P', 'CP="Not used"');
            $response->headers->remove('X-Frame-Options');
        }

        return $response;
    }