2

I am using next.js multisite plugin

https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-headless-development/the-next-js-multisite-add-on.html

I have configured 2 sites in env.sites, cft and mpoc. JSS app name is cft. I have created _site_cft and _site_mpoc rewrite paths under src/pages. But, the app always fetches cft layout data even for mpoc hostname. I have turned on the debugger on middleware and added some logs. The middleware is redirecting correctly but getstaticpaths context in [[,,path]].tsx file not containing site rewrite path. Due to this, page props factory always calling layoutdata of cft

enter image description here

enter image description here

Will be great if someone can help on this

Thanks

2
  • Why did you create rewrite paths? The multisite module encapsulates all this, you shouldn't have to be manually creating anything. The [[...path]].tsx should be in the root of the pages folder.
    – Richard Seal
    Sep 25, 2023 at 13:19
  • @RichardSeal OMG. Thank you very much i am doing it all wrong. But i have one more problem, i am getting CORS errors on _devPagesManifest.json for hostnames other than default one. How to resolve that? Thanks Sep 26, 2023 at 6:36

1 Answer 1

0

So we can mark this as answered:

In the muiltisite module, you don't need to manually create the _site_<sitename> folders, the SDK will create those for you. You need to make sure that the [[...path]].tsx file is in the root of your /src/pages folder.

This will then execute correctly and the middleware will handle the rewrites for multiple sites.

1
  • I'd like to second @bala-grorrepati on the COSR issue on hostnames other than default one (PUBLIC_URL env. variable). It tries to reach _devPagesManifest with main hostname while the initial request came for a secondary hostname then CORS errors and loops into refresh cycle Troubleshooting guide is not very descriptive on resolution, it says what we should do at a high level without explaining how exactly. It is clear we must allow cors for all the secondary domain how exactly to do that? Access-Control-Allow-Origin allowed only once and it's not clear how to pass few hostnames through it Nov 10, 2023 at 5:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.