3

I am new to Sitecore products and my company has just purchased XM Cloud. We have the request to build a backend service to expose APIs so our frontend application (built in NextJS) consumes it. The purpose of APIs is acting as a proxy to forward request to 3rd APIs.

I'm wondering is it possible to do it in XM Cloud? Can I create new custom services in backend to achieve this? Or should I forward the request directly in NextJS? Because we want other clients to use that APIs to forward requests as well if possible. Would love to hear you guys thoughts. Thank you!

1

2 Answers 2

3

You have touched on an important aspect of XM Cloud that separates it from previous versions of Sitecore. XM Cloud is not the place to be serving custom APIs from, and not the place to be doing the kind of coordination that you are talking about.

The lead architect on the XM Cloud project has said:

"You should not be using XM Cloud as compute."

We can extrapolate that statement in numerous ways, one way being that the intended purpose of XM Cloud is to serve as a CMS -- not as a place where you host custom APIs.

What you are describing can be done in the "head" of the application (Next.js); specifically, Next.js API routes allow you to build a public API that runs on the server side. So if your API needs to make calls to other APIs, or perform sensitive operations, or run GraphQL queries against your content (perhaps via Experience Edge), you can do and probably should do that in the head.

My advice would be to get familiar with JSS+GraphQL. There are available features that may meet some of your requirements. For example, you can modify GraphQL schemas and hook external APIs onto them:

https://doc.sitecore.com/xp/en/developers/hd/21/sitecore-headless-development/create-graphql-schemas.html

Lastly, if you can be more specific about what kind of APIs you want to build, that context may be helpful for other users in this community.

2
  • Thank you so much for your detailed answer. The APIs I'm about to build is just a simple POST request to Microsoft Dynamics API for getting data
    – rayray
    Nov 28, 2023 at 1:02
  • Calls to Microsoft Dynamics APIs are a common use case. This would be a good example of something you could facilitate via the API in your head application. Dec 3, 2023 at 22:20
1

You should be considering XM Cloud as an API service, not as a hosting platform or your application backend. You should have a place where you put your application logic, and it will consume all your APIs (including XM Cloud, if necessary).

In a simpler architecture, your Next.js application will be that logic and it will consume XM Cloud and any other custom APIs you build and setup. You might host those APIs in your Next.js application, or perhaps you need it as a separate layer to serve other applications as well.

In any case, your custom APIs will not sit in XM Cloud.

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.