You should replace `null === $request->server->get('HTTPS')` by `$request->isSecure()`.