Skip to content

Commit

Permalink
fixes ziggy when using SSR and determining the current URL (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald authored Jun 28, 2022
1 parent 859a8db commit e98e855
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ public function share(Request $request)
'auth' => [
'user' => $request->user(),
],
'ziggy' => function () {
return (new Ziggy)->toArray();
'ziggy' => function () use ($request) {
return array_merge((new Ziggy)->toArray(), [
'location' => $request->url(),
]);
},
]);
}
Expand Down
2 changes: 1 addition & 1 deletion stubs/inertia-react/resources/js/ssr.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ createServer((page) =>
global.route = (name, params, absolute) =>
route(name, params, absolute, {
...page.props.ziggy,
location: new URL(page.props.ziggy.url),
location: new URL(page.props.ziggy.location),
});

return <App {...props} />;
Expand Down
2 changes: 1 addition & 1 deletion stubs/inertia-vue/resources/js/ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ createServer((page) =>
.use(plugin)
.use(ZiggyVue, {
...page.props.ziggy,
location: new URL(page.props.ziggy.url),
location: new URL(page.props.ziggy.location),
});
},
})
Expand Down

0 comments on commit e98e855

Please sign in to comment.