What are some common pitfalls when deploying and configuring an XDN app with Spartacus?
Some common pitfalls when deploying and configuring an XDN app with Spartacus:
- Not having SSR . Integration with XDN will not work without SSR being implemented. The XDN prefetching works in Spartacus by using SSR-ed pages to understand what resources need to be prefetched in order to make the app faster. Make sure that your app has enabled SSR: Server-Side Rendering - Spartacus Documentation
Multiple projects in your angular.json file . If you have multiple projects in your
angular.jsonfile, the XDN will, by default, use the
defaultProjectin that file to configure the right project. If you need to configure a project that is NOT the
defaultProject, use the
ANGULAR_PROJECTenvironment variable when running the xdn commands, like it is explained here: Moovweb XDN Documentation - Spartacus
Use the right OCC endpoint . The
baseUrlshould be updated to use the endpoint of your app when it’s running on the XDN. This is because your router will now proxy those API calls through the XDN and on to your OCC backend. So, make sure that this correctly configured as described here for maximum effectiveness: Moovweb XDN Documentation - Spartacus
- Configure your SSR-ed routes in your router . Your router file will come with a preconfigured example route for your SSR-ed pages, but make sure to update it with the right routes for your SSR endpoints. Having these routes configured with a cache specified is what will trigger the XDN Prefetcher to request the API results for each SSR-ed page.