Skip to content

Commit f0f0b04

Browse files
committed
dev ssr
1 parent 141256b commit f0f0b04

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Diff for: src/Ssr/HttpGateway.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,29 @@
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+
}
15+
1016
/**
1117
* Dispatch the Inertia page to the Server Side Rendering engine.
1218
*/
1319
public function dispatch(array $page): ?Response
1420
{
15-
if (! config('inertia.ssr.enabled', true) || ! (new BundleDetector)->detect()) {
21+
if ($this->vite->isRunningHot()) {
22+
$url = file_get_contents($this->vite->hotFile()).'/render';
23+
} elseif (config('inertia.ssr.enabled', true) || (new BundleDetector)->detect()) {
24+
$url = str_replace('/render', '', config('inertia.ssr.url', 'http://127.0.0.1:13714')).'/render';
25+
} else {
1626
return null;
1727
}
1828

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

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

0 commit comments

Comments
 (0)