Reputation: 3
We are using Multi-Site setup in Spartacus. It works fine, however when user enters URL with incorrect baseSite, Spartacus shows a blank page and throws an error in JS console Error: Cannot get base site config! Current url (https://www.example.com/xyz/) doesn't match any of url patterns of any base sites.
(xyz
is the incorrect baseSite identifier in this example).
Is there a way to handle this error and redirect user e.g. to 404 not found page in this case?
Upvotes: 0
Views: 1460
Reputation: 423
You have to implement your own class based on SiteContextConfigInitializer
and override the method resolveConfig
. Then add it to providers in your module: { provide: SiteContextConfigInitializer, useClass: YourSiteContextConfigInitializer }
. Unfortunatelly I guess you must add also own methods for isCurrentBaseSite
and get currentUrl
(just copy and rename) because they are private.
Upvotes: 0