Debugging production SSR

Sometimes errors during Server Side Rendering only occur in the compiled version of the server and not in development mode. If this is happening to you, you'll need to run the production version of the SSR process.

🚧

This debugging is only possible when running the webpack on a new Frontastic sandbox and not your local or existing sandbox (switching between these modes will break your setup and leave the sandbox in a malfunctioning state).

To run the production version of the SSR process, follow the steps below:

  1. Create a new Frontastic sandbox (see bringing up a Frontastic sandbox for more information)

  2. Run frontastic init to connect the Frontastic CLI with your newly created sandbox and select Copy changes to the Frontastic sandbox where webpack runs (see this article for more information about the Frontastic CLI set up questions)

  3. Execute the below command to disable the SSR process that's currently running:

sudo supervisorctl stop <customer>-<project>:<customer>-<project>-server-run-00

<customer> is your customer name and <project> is your project id (for example, if <customer> = demo and <project> = english the command would be sudo supervisorctl stop demo-english:demo-english-server-run-00)

This will make sure that the configured port is free.

  1. Run the production compiled version of the SSR process:
NODE_ENV=production node <customer>_<project>/bin/server.js
  1. Make a request to your site and you'll get the production SSR result from the running process

If something goes wrong, you'll also see an error output on the CLI dashboard from that running process.

Rebuilding the production assets using your sandbox

Unfortunately, this process isn't completely supported on the Frontastic sandbox and you'll run into errors stating that there's no git available. We're aware of this, but you're still able to regenerate the assets by running ant prepare and just ignoring the git errors at the end.

These only occur because we'd commit the built assets once they're ready, so the changed files should already be there in the filesystem of the Frontastic sandbox. You can just stop the command executed at step 4 and execute it again using the updated server.js after running ant prepare in the project directory on the Frontastic sandbox.


Did this page help you?