HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //home/xedaptot/iphim.naniguide.com/common/SSR/RenderPageWithNode.php
<?php

namespace Common\SSR;

use Common\ServerTiming\ServerTiming;
use Exception;
use Illuminate\Support\Facades\Http;

class RenderPageWithNode
{
    public function execute(array $bootstrapData): ?string
    {
        if (
            !config('common.site.ssr_enabled') ||
            request('appearanceEditor') === 'true'
        ) {
            return null;
        }

        $serverUrl = config('common.site.ssr_url') . '/render';

        try {
            app(ServerTiming::class)->start('SSR');
            $response = Http::withHeaders([
                'Accept-encoding' => 'gzip',
            ])
                ->post($serverUrl, [
                    'bootstrapData' => $bootstrapData,
                    'url' => request()->getRequestUri(),
                ])
                ->throw()
                ->body();
            app(ServerTiming::class)->stop('SSR');
        } catch (Exception $e) {
            return null;
        }

        if (is_null($response)) {
            return null;
        }

        return $response;
    }
}