Skip to content

Commit

Permalink
dev ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmajor committed Oct 11, 2024
1 parent 141256b commit f0f0b04
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Ssr/HttpGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@
namespace Inertia\Ssr;

use Exception;
use Illuminate\Foundation\Vite;
use Illuminate\Support\Facades\Http;

class HttpGateway implements Gateway
{
public function __construct(
private Vite $vite,
) {
}

/**
* Dispatch the Inertia page to the Server Side Rendering engine.
*/
public function dispatch(array $page): ?Response
{
if (! config('inertia.ssr.enabled', true) || ! (new BundleDetector)->detect()) {
if ($this->vite->isRunningHot()) {
$url = file_get_contents($this->vite->hotFile()).'/render';
} elseif (config('inertia.ssr.enabled', true) || (new BundleDetector)->detect()) {
$url = str_replace('/render', '', config('inertia.ssr.url', 'http://127.0.0.1:13714')).'/render';
} else {
return null;
}

$url = str_replace('/render', '', config('inertia.ssr.url', 'http://127.0.0.1:13714')).'/render';

try {
$response = Http::post($url, $page)->throw()->json();
Expand Down

0 comments on commit f0f0b04

Please sign in to comment.