inertiajs / inertia

Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers.
https://inertiajs.com
MIT License
6.3k stars 423 forks source link

NOT FOUND JSON reponse when starting with SSR #1813

Closed Axiol closed 4 months ago

Axiol commented 7 months ago

Version:

Describe the problem:

I created a new Laravel project and followed the steps to implement Inertia. Everything works fine. Then I tried implementing SSR. I followd the doc. But when I run php artisan inertia:start-ssr, I get a JSON response

{"status":"NOT_FOUND","timestamp":1709161161326}

Steps to reproduce:

Clone this project, install everything, run npm run build, and start with php artisan inertia:start-ssr

RobertBoes commented 7 months ago

I can't replicate the issue, cloned the project but it works as expected, the only thing I'm seeing is some hydration errors.

Just a few things to note:

Axiol commented 7 months ago

I pushed a commit with dummy data on the same branch as my link. So /en-continu should work even without the env

But it is still the same. Just to be sure, what is the URL you visit after starting the project? I put http://localhost:13714/en-continu as suggested by the prompt

image

RobertBoes commented 7 months ago

You wouldn't visit the Inertia SSR server. You just visit your app as usual, Inertia then uses the SSR server to grab the rendered HTML and render it in the blade template

Axiol commented 7 months ago

Oh. My bad then... Just to be sure, what need to be running at the same time? The app, the SSR server and the node server?

reinink commented 4 months ago

Oh. My bad then... Just to be sure, what need to be running at the same time? The app, the SSR server and the node server?

So just run your Laravel app like you always have, and then in production run php artisan inertia:start-ssr, which will use Node in the background to do SSR. These days Forge has built-in support for this, which makes it really easy to get up and running.

As @RobertBoes suggested you don't ever visit the SSR node server, that's just a process running in the background that the Inertia Laravel communicates with it automatically 👍