Skip to content

Commit 6fa3696

Browse files
committed
dev ssr
1 parent 141256b commit 6fa3696

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Ssr/HttpGateway.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,28 @@
33
namespace Inertia\Ssr;
44

55
use Exception;
6+
use Illuminate\Foundation\Vite;
67
use Illuminate\Support\Facades\Http;
78

89
class HttpGateway implements Gateway
910
{
11+
public function __construct(
12+
private Vite $vite,
13+
) {
14+
}
1015
/**
1116
* Dispatch the Inertia page to the Server Side Rendering engine.
1217
*/
1318
public function dispatch(array $page): ?Response
1419
{
15-
if (! config('inertia.ssr.enabled', true) || ! (new BundleDetector)->detect()) {
20+
if ($this->vite->isRunningHot()) {
21+
$url = file_get_contents($this->vite->hotFile()).'/render';
22+
} elseif (config('inertia.ssr.enabled', true) || (new BundleDetector)->detect()) {
23+
$url = str_replace('/render', '', config('inertia.ssr.url', 'http://127.0.0.1:13714')).'/render';
24+
} else {
1625
return null;
1726
}
1827

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

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

0 commit comments

Comments
 (0)