Skip to content

Commit

Permalink
Fix bug where SSR is dispatched twice when errors exist (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
reinink authored Jan 14, 2023
1 parent dfa8425 commit c07625d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Directive.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ public static function compile($expression = ''): string
$id = trim(trim($expression), "\'\"") ?: 'app';

$template = '<?php
if (!isset($__inertiaSsr)) {
$__inertiaSsr = app(\Inertia\Ssr\Gateway::class)->dispatch($page);
if (!isset($__inertiaSsrDispatched)) {
$__inertiaSsrDispatched = true;
$__inertiaSsrResponse = app(\Inertia\Ssr\Gateway::class)->dispatch($page);
}
if ($__inertiaSsr instanceof \Inertia\Ssr\Response) {
echo $__inertiaSsr->body;
if ($__inertiaSsrResponse) {
echo $__inertiaSsrResponse->body;
} else {
?><div id="'.$id.'" data-page="{{ json_encode($page) }}"></div><?php
}
Expand All @@ -36,12 +37,13 @@ public static function compile($expression = ''): string
public static function compileHead($expression = ''): string
{
$template = '<?php
if (!isset($__inertiaSsr)) {
$__inertiaSsr = app(\Inertia\Ssr\Gateway::class)->dispatch($page);
if (!isset($__inertiaSsrDispatched)) {
$__inertiaSsrDispatched = true;
$__inertiaSsrResponse = app(\Inertia\Ssr\Gateway::class)->dispatch($page);
}
if ($__inertiaSsr instanceof \Inertia\Ssr\Response) {
echo $__inertiaSsr->head;
if ($__inertiaSsrResponse) {
echo $__inertiaSsrResponse->head;
}
?>';

Expand Down

0 comments on commit c07625d

Please sign in to comment.