dalejmooney's avatar

Cannot read properties of undefined

I am using Laravel 11, Vue3 and Inertiajs along with Typescript. I am trying to setup SSR

My ssr.ts is as follows

import { createInertiaApp } from '@inertiajs/vue3';
import createServer from '@inertiajs/vue3/server';
import { renderToString } from '@vue/server-renderer';
import { createSSRApp, DefineComponent, h } from 'vue';
import { ZiggyVue } from 'ziggy-js';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';

createServer(page =>
  createInertiaApp({
    page,
    render: renderToString,
    resolve: (name) =>
      resolvePageComponent(
        `./Pages/${name}.vue`,
        import.meta.glob<DefineComponent>('./Pages/**/*.vue'),
      ),
    setup({ App, props, plugin }) {
      return createSSRApp({
        render: () => h(App, props)
      }).use(plugin).use(ZiggyVue);
    }
  })
);

I followed the instructions etc and I run

npm run build

Which runs ok, then I try

Starting SSR server on port 13714...
Inertia SSR server started

And that runs ok, but when I refresh the site, I get the error

TypeError: Cannot read properties of undefined (reading 'welcome')

Which looks like its on the route...I have been looking around for ages and cannot seem to fix it.

2 likes
1 reply
Smash's avatar

I've got the same error and also have not figured out how to get the node server error about the location to go away. The pages and markup are coming down fine - but this error - I can't seem to find it either.

Please or to participate in this conversation.