fix(ssr): remove conflicting RouteMixin that caused 'Cannot read properties of undefined (reading index)'

RouteMixin received the full Inertia page object instead of page.props,
producing a Ziggy config without routes. ZiggyVue already provides the
route() function with the correct config, so the duplicate mixin is
unnecessary.
This commit is contained in:
F4ilji
2026-07-05 21:47:03 +05:00
parent a80a60bdbe
commit 09771bf8ad
-10
View File
@@ -4,8 +4,6 @@ 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 { default as Router } from '../../vendor/tightenco/ziggy/dist/index.m.js';
import { createRouteMixin } from './mixins/RouteMixin.js';
import { createSsrErrorHandler, logSsrError } from './ssr/errorHandler.js';
createServer(page =>
@@ -21,7 +19,6 @@ createServer(page =>
render: () => h(App, props),
});
// SSR error handler - logs to separate file
const ssrErrorHandler = createSsrErrorHandler();
ssrApp.config.errorHandler = ssrErrorHandler;
ssrApp.config.warnHandler = () => null;
@@ -30,25 +27,18 @@ createServer(page =>
...page.props.ziggy,
};
// SSR-safe location handling
if (page.props.ziggy?.location) {
ziggyConfig.location = new URL(page.props.ziggy.location);
} else {
ziggyConfig.location = new URL(process.env.APP_URL || 'http://localhost');
}
// Добавляем route mixin для всех компонентов
const routeMixin = createRouteMixin(page, Router);
ssrApp.mixin(routeMixin);
return ssrApp
.use(plugin)
.use(ZiggyVue, ziggyConfig);
},
}).catch(error => {
// Catch Inertia SSR errors and log them separately
logSsrError(error);
// Re-throw to maintain normal error flow
throw error;
})
);