Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOT FOUND JSON reponse when starting with SSR #1813

Closed
Axiol opened this issue Feb 28, 2024 · 5 comments
Closed

NOT FOUND JSON reponse when starting with SSR #1813

Axiol opened this issue Feb 28, 2024 · 5 comments
Labels
react Related to the react adapter

Comments

@Axiol
Copy link

Axiol commented Feb 28, 2024

Version:

  • @inertiajs/react version: 1.0.15

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

@Axiol Axiol added the react Related to the react adapter label Feb 28, 2024
@RobertBoes
Copy link
Contributor

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:

  • Setting up the repo is kinda impossible, as you're using an env value (BFF_URL), which is required but there's no info on what it is and how to replicate it. I'd suggest to create repo/branch that just deals with dummy data, that way it wouldn't even be a requirement and it's just an install and run.
  • I see you have laravel/sail as a requirement, if you're running your app through Sail you'd need to run the Inertia SSR server within the Sail container, see https://laravel.com/docs/10.x/sail#executing-sail-commands. So you'd need to run sail artisan inertia:start-ssr
  • Not really relevant, but you're using env() within app code, you should only use that in config files. As per the warning here https://laravel.com/docs/10.x/configuration#configuration-caching the env() helper will return null in app code when config is cached.

@Axiol
Copy link
Author

Axiol commented Feb 29, 2024

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
Copy link
Contributor

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
Copy link
Author

Axiol commented Feb 29, 2024

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
Copy link
Member

reinink commented May 28, 2024

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 👍

@reinink reinink closed this as completed May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
react Related to the react adapter
Projects
None yet
Development

No branches or pull requests

3 participants