fix(ssr): embed Ziggy routes as fallback for SSR context

ZiggyVue needs routes in its config, but page.props.ziggy from the
server may not carry them in the SSR worker. Importing the static
Ziggy config ensures routes are always available.
This commit is contained in:
F4ilji
2026-07-05 21:56:51 +05:00
parent 09771bf8ad
commit a372f725cd
+5 -6
View File
@@ -4,6 +4,7 @@ import createServer from '@inertiajs/vue3/server'
import { renderToString } from '@vue/server-renderer'
import { createSSRApp, h } from 'vue'
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';
import { Ziggy } from './ziggy';
import { createSsrErrorHandler, logSsrError } from './ssr/errorHandler.js';
createServer(page =>
@@ -24,15 +25,13 @@ createServer(page =>
ssrApp.config.warnHandler = () => null;
const ziggyConfig = {
...Ziggy,
...page.props.ziggy,
location: page.props.ziggy?.location
? new URL(page.props.ziggy.location)
: new URL(process.env.APP_URL || 'http://localhost'),
};
if (page.props.ziggy?.location) {
ziggyConfig.location = new URL(page.props.ziggy.location);
} else {
ziggyConfig.location = new URL(process.env.APP_URL || 'http://localhost');
}
return ssrApp
.use(plugin)
.use(ZiggyVue, ziggyConfig);