Search code examples
spartacus-storefront

SSR rendering exceeded timeout, fallbacking to CSR for (all routes)


I created a new angular project and ran the following command: ng add @spartacus/schematics --baseUrl https://spartacus-demo.eastus.cloudapp.azure.com:8443/ --baseSite=electronics-spa --ssr. After, I ran the command npm run dev:ssr, opened http://localhost:4200 and found the following problem:

enter image description here

Any ideas how to correct this bug and make the app run SSR instead of CSR? This warning message is showing for every route I try to access.

(https://github.com/SAP/spartacus/issues/10638)


Solution

  • it's because of SSR optimization feature available in Spartacus 3.0 and up.

    You can either extend the timeout in your server.ts (passing a second parameter to NgExpressEngineDecorator.get method) or set it to 0, so it won't be fallbacking to CSR at all. Here is an example:

    const ngExpressEngine = NgExpressEngineDecorator.get(engine, { timeout: 0 });
    

    You can use API documentation to get a list of available options: https://sap.github.io/spartacus/interfaces/SsrOptimizationOptions.html

    Additionally, an extended documentation regarding this feature is on its way and should be available soon.