pok
pok

Reputation: 3

"Cannot get base site config" error in Spartacus

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

Answers (1)

Michał Gruca
Michał Gruca

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

Related Questions