Reputation: 208
we are planning to migrate 1 hybris application from the accelerator storefront to Spartacus. we planned page by page approach, that some pages loaded from the accelerator storefront and some pages from Spartacus. can someone provide some idea on how we can implement this?
For example : this catalog page loads from spartacus : http://localhost:4200/electronics-spa/en/USD/Open-Catalogue/Cameras/Digital-Cameras/c/575
and this cart page loads from accelerator storefront- http://localhost:4200/electronics-spa/en/USD/cart
Upvotes: 1
Views: 295
Reputation: 1430
The out of the box Spartacus offers external routes to solve this problem. This is build on top of the angular routerlink
You can specify which routes are handled by the angular application, and which need to be fetched from the backend (accelerator setup)
ConfigModule.withConfig({
routing: {
internal: [
'/',
'/cart',
'/product/*/*',
'/**/p/**',
]
}
})
With this config, you specify what routes are served by the single page applications, the others will be fetched from the backend
If you make use of a single page application (SPA), you will also need to configure the service worker to bypass the caching worker. this in done in ngsw-config.json
"navigationUrls": [
// prefix `/*/*/*/` handles the three site context URL segments
'/*/*/*/',
'/*/*/*/cart',
'/*/*/*/product/*/*',
'/*/*/*/**/p/**',
]
For more information: https://sap.github.io/spartacus-docs/external-routes/#using-spartacus-and-another-system-to-run-a-single-storefront
Upvotes: 2