From a372f725cd6f6d4b729634fa3e9bfc04a252ba56 Mon Sep 17 00:00:00 2001 From: F4ilji Date: Sun, 5 Jul 2026 21:56:51 +0500 Subject: [PATCH] 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. --- resources/js/ssr.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/resources/js/ssr.js b/resources/js/ssr.js index d61f4b8..556fccb 100755 --- a/resources/js/ssr.js +++ b/resources/js/ssr.js @@ -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);