inertiajs / inertia-laravel

The Laravel adapter for Inertia.js.
https://inertiajs.com
MIT License
2.08k stars 234 forks source link

Pass through NODE_ENV to Node-based Inertia SSR server #517

Closed hjanos1 closed 5 months ago

hjanos1 commented 1 year ago

Got an error like the one below, so I have realized that process.env.NODE_ENV === 'production' checks always detect that the environment is not production on the SSR node server, sometimes leading to debug mode behaviour and skipping of production optimizations.

This PR solves the issue by passing through Laravel's environment to the Node-based Inertia SSR server when starting the server through the inertia:start-ssr command.

Error mentioned:

SerializableStateInvariantMiddleware took 35ms, which is more than the warning threshold of 32ms. If your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions. It is disabled in production builds, so you don't need to worry about that.
jameshulse commented 1 year ago

Seeing as NODE_ENV would usually either be development or production: would it make sense to pass production if the app()->environment is production, or pass development otherwise? That avoids it being set to 'local' for example which wouldn't be a useful value in most cases, but is common in Laravel.

driesvints commented 5 months ago

Heya. We removed our master branch. Feel free to re-attempt this to 1.x!