@@ -3,7 +3,7 @@ import createServer from '@inertiajs/vue3/server'
33import { renderToString } from '@vue/server-renderer'
44import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'
55import { createSSRApp , DefineComponent , h } from 'vue'
6- import { route as ziggyRoute } from 'ziggy-js'
6+ import { route as ziggyRoute , Config } from 'ziggy-js'
77
88const appName = import . meta. env . VITE_APP_NAME || 'Laravel Starter Template'
99
@@ -18,18 +18,25 @@ createServer((page) =>
1818
1919 // Configure Ziggy for SSR...
2020 const ziggyConfig = {
21- ...page . props . ziggy ,
22- location : new URL ( page . props . ziggy . location )
21+ ...( page . props . ziggy as Config ) ,
22+ location : new URL ( ( page . props . ziggy as { location : string } ) . location )
2323 }
2424
2525 // Create route function...
26- const route = ( name : string , params ?: any , absolute ?: boolean ) => ziggyRoute ( name , params , absolute , ziggyConfig )
26+ const route = ( ( name ?: string , params ?: any , absolute ?: boolean ) => {
27+ if ( ! name ) return ziggyRoute ( undefined , undefined , absolute , ziggyConfig )
28+ return ziggyRoute ( name , params , absolute , ziggyConfig )
29+ } ) as {
30+ ( ) : any ;
31+ ( name : string , params ?: any , absolute ?: boolean ) : string ;
32+ }
2733
2834 // Make route function available globally...
2935 app . config . globalProperties . route = route
3036
3137 // Make route function available globally for SSR...
3238 if ( typeof window === 'undefined' ) {
39+ // @ts -expect-error - This is a global variable
3340 global . route = route
3441 }
3542
0 commit comments