Can you track down where you use window? As far as I know ssr does not have access to window as it isn't compiling to a browser
Mar 8, 2022
3
Level 11
Inertia.js + SSR
I'm trying out inertia with SSR. I have my project setup pretty much the same as the "Build Modern Laravel Apps Using Inertia.js" series. However, when I try to serve my ssr.js file and access it via browser, the server errors out and falls back to js
ReferenceError: window is not defined
at normalizeContainer (/home/shortbrownman/sites/reach/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:1611:5)
at Object.app.mount (/home/shortbrownman/sites/reach/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:1556:27)
at setup (/home/shortbrownman/sites/reach/public/js/ssr.js:2129:176)
at /home/shortbrownman/sites/reach/node_modules/@inertiajs/inertia-vue3/dist/index.js:1:9464
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Server.<anonymous> (/home/shortbrownman/sites/reach/node_modules/@inertiajs/server/lib/index.js:46:37)
I think it might have something to do with vendor extraction or setting the Layout file asynchronously in my app.js file. I'm not really sure but those are two points that deviate from the Inertia SSR documentation that I can see.
Please or to participate in this conversation.