I’m trying to deploy a Laravel application using Inertia.js with server-side rendering (SSR). However, when I navigate between links, I encounter the following error:
All Inertia requests must receive a valid Inertia response, however a plain JSON response was received.
My Setup:
- Vue component link:
<Link :href="route('welcome')" class="me-4 hover:underline md:me-6">
Annonser
</Link>
(I have imported Link from @inertiajs/vue3.)
- Route definition:
return Inertia::render('Welcome');
Server details:
- Ubuntu 24.10
- Nginx 1.26.0
- PHP 8.3.11
php artisan inertia:start-ssris running and active.
Observations:
- TCPDump:
When I use tcpdump on port 13714, I see traffic on the initial request. But when I try to navigate within the app, no traffic appears on this port, and the error occurs.
- Nginx Configuration Quirk:
If I modify my Nginx configuration so the default server block (using the IP xxx.xxx.xxx.xxx) points to laravel/public instead of the domain name (example.com), the navigation works as expected. But still tcpdump only show traffic on the initial request.
- Curl Request:
When I run curl 127.0.0.1:13714, I get:
{"status":"NOT_FOUND","timestamp":1733846743327}
php artisan inertia:start-ssr is runnig.
- JavaScript Behavior:
When I disable JavaScript, the content disappears entirely.
Potential Issue:
Could this be related to a hostname misconfiguration in the SSR setup? I’ve ensured the X-Inertia header is present, but I still can’t figure out why it only works with the IP-based configuration.
Any help or insights on how to resolve this issue would be greatly appreciated!
UPDATE: When i disable javascript for my site, i get full page reloads now. Dont know if it was because i changed app.js
from
return createApp({ render: () => h(App, props) })
to
return createSSRApp({ render: () => h(App, props) })
This according to https://inertiajs.com/server-side-rendering. But 99% of users will have javascript enabled, so the error persists.
When php artisan inertia:start-ssr is running, and javascript is disabled, all links seems to be working. But when javascript is enabled, i still get Laravel Inertia.js SSR Error: “All Inertia requests must receive a valid Inertia response”. What is the cause?