Posts

Showing posts from August, 2023

Multisite configuration in Next.js application using Middleware

Image
This is a very common requirement where we need to achieve the multisite/multitenant capability while developing Next JS frontend application using Sitecore CMS in headless manner. Next.js application uses Next.js Middleware to serve the correct Sitecore site based on the incoming hostname.  Middleware Middleware allows you to run code before a request is completed. It allows you to add additional functionality or perform tasks such as modify response by redirecting, rewriting, modifying the headers. Multisite add-on By default, the Next.js Multisite add-on fetches a list of site information directly from your Sitecore instance, and all sites are statically generated at build time. It also uses Next.js Middleware to serve the correct Sitecore site. But Multisite add-on have there own limitations where config-based site definitions are not currently included. Only SXA-based sites will be fetched.  You can add this add-on using the JSS initializer . An XM Cloud project based on a Starter

Sitecore Item Service Rest APIs for Client Apps

Image
The Item Service REST API allows you to interact with Sitecore items directly. This is very useful specially when you want to develop a data-driven client application including JavaScript application to interact with the Sitecore items without having Sitecore context.  Sitecore.Services.Client provides two services: ItemService : This service gives you access to regular Sitecore items. EntityService : This service gives you access to business objects that you define. In this article, I will show you the implementation of the Item Service API using .NET Console application. The ItemService REST API allows the following operations: CRUD - Create, Read, Update and Delete Item Sitecore Search Execute Stored Item Queries You may refer the Official Sitecore Documentation – ItemService REST API for more details. Request and Response flow : This is pretty straightforward flow where you need to authenticate first with the respective Sitecore instance and then perform the different requests as