Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multisite / Single site is not working with XM cloud .net SDK (Always looking for default site name property) #23

Open
1 task done
Nelsjnjr123 opened this issue Nov 18, 2024 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@Nelsjnjr123
Copy link

What happened?

Description

I have tried to enable the XM cloud multisite by following the readme file provided in the repo, I have provided the "EdgeContextId" and "EditingSecret", but I'm not able to see the multisite based on the domain name I have configured in Sitecore, I have deployed this rendering host to Azure web app, and I have configured the same domain names in the Sitecore, but still multisite not working

Reproduction Steps
1. Open
Clone the XM cloud repo for asp.net SDK and update the "EdgeContextId" and "EditingSecret" without providing the default site name, Configure 2 sites in XM cloud and update the domain names for the 2 sites, now deploy the rendering host to Azure web app and browse the domain

2. Execute

Once the web app is deployed to Azure, now browse the configured domain in the Sitecore

Actual Behavior

It throws an error, and the site is not resolving, this is because the code is expecting the Default site name to be added in the appsettings, but if we provide the default site name, then the site works but not as multisite, it only loads the site which we configured as default site in the appsetting.

In Local development, I tried to load multisite with DEV tunnels. Still, it is resolving as localhost in the code, so I hope the domain will not be resolved for the multisite scenario in Local, but it is even not working when deployed to Azure.

In Local development, even in a single site scenario the code always looks for the default site name property to be filled in appsettings.

Expected Behavior

The correct site should be resolved based on the domain name URL(for sitea and siteb) without setting the default site name.

Reference:
Sitecore domain name
appsetting without default sitename
Site name missing

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Nelsjnjr123 Nelsjnjr123 added the bug Something isn't working label Nov 18, 2024
@sc-ivanlieckens
Copy link
Collaborator

@Nelsjnjr123 thank you for your report. Could I ask your middleware configuration? Did you add UseMultisite() to your Application Builder?

@sc-ivanlieckens sc-ivanlieckens self-assigned this Nov 18, 2024
@Nelsjnjr123
Copy link
Author

Thank you, I have used in program.cs , Please find the below screenshot.

usemultisite

@Nelsjnjr123 Nelsjnjr123 changed the title Multisite / Single site is not working with XM cloud .net SDK (Always looking for dafault site name property) Multisite / Single site is not working with XM cloud .net SDK (Always looking for default site name property) Nov 18, 2024
@Nelsjnjr123
Copy link
Author

Also, I have not added the builder.Services.AddMultiSite() to the above code.
because if I try to add the AddMultiSite() I'm getting the below error.
Addmultisite service

@sc-ivanlieckens
Copy link
Collaborator

@Nelsjnjr123 1 important thing about UseMultisite() is that it must be configured before UseSitecoreRenderingEngine() otherwise the middleware order is incorrect (multisite must be resolved before the rendering engine makes the layout request)

As to the AddMultisite() failing on your services collection, did you configure AddGraphQlClient()?

Could you provide the full configuration code you're using?

@Nelsjnjr123
Copy link
Author

Please find the attached program.cs, Kindly let me know if im missing any thing.

Program.zip

@sc-ivanlieckens
Copy link
Collaborator

@Nelsjnjr123 we investigated the issue further and it appears you're missing some configuration. To ease things we're adding an example to the starterkit: Sitecore/xmcloud-starter-dotnet#15

I had identified this awkward dependencies issue and flagged it for cleanup before the final release. I agree it's not intuitive that a double GQL configuration must be made for this specific feature. It raises the question on how standalone the Sitecore.AspNetCore.SDK.LayoutService.Client should be however and thus requires further deliberation before we make the changes as this will most definitely impact how the initialization and app config is executed in the future.

@Nelsjnjr123
Copy link
Author

Hi @sc-ivanlieckens,

I have taken the latest Main branch of the starter kit and deployed to the code to Azure web app, but still I'm getting the same site not passed error. Please let me know on this, I have verified the code that now I could see the multisite middleware added in the program.cs by Rob, but still not resolving the site unless we are passing the default site name.

Thanks
Nelson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants