Showing results for 
Search instead for 
Did you mean: 

The default canonical URL is set to localhost instead of domain URL. How to resolve this?

Hi, Everyone.

With Spartacus 4.0 onwards, the canonical URL is configured to be default as below. However, the canonical URL for PDP page has local IP address in quality and production environment. The other pages have the domain name as expected. Any help to resolve this

pageMeta: {
    canonicalUrl: {
      forceHttps: true,
      forceWww: false,
      removeQueryParams: true,
      forceTrailingSlash: true

Setting it manually on PDP controller also didn't help. Any help to resolve this will be appreciated. Thanks!

View Entire Topic
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi manja1207

I verified Spartacus 4.3 on my end, it's working fine. The canonical URL is not hardcoded anywhere in the source codes, by default it takes the page route including the domain names as part of the canonical URL.

Please see the screenshot where I changed the port number just for testing purpose.

If the issue persists on your end, please could you let us know how to reproduce the same?


Thanks for the response, samuel.yang.

Our setup followed instruction from here to setup TUA Spartacus storefront. It has Spartacus 4.3.5 and SSR enabled.

The canonical URL on our local development also shows current route, just like your screenshot but the problem arises after deployment. Once deployed, the canonical URL (only on PDP) has localhost IP address.

PS: Also the canonical URL is not part of DOM elements in our case. It is found in 'View Source' option of the webpage.