0
votes

I am trying to add Multisite in my Spartacus application. I have two domain names (let's say abc.in and xyz.in). Whenever I hit abc.in it should redirect to abc.in/electronic-spa/en and while hitting xyz.in it should redirect to xyz.in/apparal/en.

How to achieve this using MultiSite configurations in Spartacus?

1
Yes. I refer to that link. But I didn't get a clear idea of how to do it with the different domain names and multiple sites. Kindly help me to resolve this.Selva Ajitha
Kindly help me to do it for multiple sites with different domains.Selva Ajitha

1 Answers

0
votes

Multisite works with the following mechanism:

  • Multiple sites (BaseSite) are setup in the commerce backend. Each site might have a custom product and content catalog, but it's quite flexible to mix and match it all together. Customer are using a variety of combinations to end up with the actual site/content that they need for a specific market.
  • Almost all API endpoints have the site.uid as part of the url. The API therefor can easily understand which content to return.
  • If the same storefront application (Spartacus in this case) should use a single API, the storefront actually must know the site.uid, so it can construct the right API endpoint. The storefront would normally not know this unless you hard-code it.
  • The commerce platform comes with a capability to link the storefront URL to the basesite, by using so-called regular expressions. A basesite can have multiple regex to configure to which storefront url the base site belongs. This is a very old mechanism in the commerce backend, that has been used in the (java) CmsSiteFilter. In spartacus we cannot use this filter, but we're using a similar filter mechanism. The same regex patterns are used, to filter the site, but it's done client side.

What you'd need to do to get it working:

  • use minimal 1905 version on the backend (otherwise the /basesites endpoint is not available)
  • setup your local hosts file, to mimic domain based URLs locally
  • setup the basesite regex (urlPatterns) so that it will match the actual domain URLs
  • run your Spartacus app with the --disable-host-check flag, so that it will listen to any local domain.