Hello,
so I finally managed to get almost to finish when starting Inertia SSR, but I got stuck at this at the end:
php artisan inertia:start-ssr
Starting SSR server on port 13714...
Inertia SSR server started.
but when I start to actualy interact with the page
TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received undefined
at new NodeError (node:internal/errors:405:5)
at write_ (node:_http_outgoing:879:11)
at ServerResponse.write (node:_http_outgoing:838:15)
at Server.<anonymous> (file:///xxxxxxxxxx/node_modules/@inertiajs/core/dist/server.esm.js:1:506)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_INVALID_ARG_TYPE'
}
my ssr.js
import '../css/app.css';
import { createInertiaApp } from '@inertiajs/vue3'
import createServer from '@inertiajs/vue3/server'
import { renderToString } from '@vue/server-renderer'
import {createSSRApp, h, onMounted, ref} from 'vue'
import { renderSSRHead } from '@unhead/ssr'
import {createPinia} from "pinia";
import {createHead} from "@unhead/vue";
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';
const head = createHead()
const payload = renderSSRHead(head)
const CTAModalOpened = ref(false);
const SearchBarOpened = ref(false);
const pinia = createPinia();
createServer(page => {
createInertiaApp({
page,
render: renderToString,
resolve: name => {
const pages = import.meta.glob('./Pages/**/*.vue', {eager: true})
return pages[`./Pages/${name}.vue`]
},
setup({App, props, plugin}) {
const Ziggy = {
...props.initialPage.props.ziggy,
location: new URL(props.initialPage.props.ziggy.url)
}
return createSSRApp({render: () => h(App, props),})
.use(plugin)
.use(ZiggyVue, Ziggy)
.use(head)
.use(pinia)
.provide('cta_modal_opened', CTAModalOpened)
.provide('search_bar_opened', SearchBarOpened)
}
})
})
vite.config.js
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import path from 'path';
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
ssr: 'resources/js/ssr.js',
refresh: true,
}),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
build: {
target: 'esnext'
},
ssr: {
noExternal: ['@inertiajs/server'],
},
resolve: {
alias: {
ziggy: path.resolve('vendor/tightenco/ziggy/dist/index.es.js'),
ziggyVue: path.resolve('vendor/tightenco/ziggy/dist/vue.es.js'),
},
},
});
any suggestions?