0

I was working on sitecore Headless with Next Js. I have created a sample application with few components and it is working fine in local. Now I tried to deploy this application to vercel.Since the sitecore host is local and is not available in public it is not accessible and deployment fails. Also in our case the QA sitecore host has SSO authentication so I assume in QA also vercel will not be able to access the sitecore host. So wanted to understand if there is any workarounds in such cases.

1
  • Did you use JSS to create the app?
    – Richard Seal
    Commented Mar 29, 2023 at 15:59

2 Answers 2

3

Since you have our Sitecore instance running locally, you need to expose your local host URL to the public internet. There are multiple reverse proxy tools to do this like ngrok and localtunnel. I have used ngrok for the local development and it worked pretty well. Below are the steps to configure:

  • Go to https://ngrok.com. Register and create a free account to get the auth token. Start the tunnel. All the steps are mentioned here. @Sebastian has also written a nice blog to explain the Ngrok set up.

  • Now you need to create the tunnel for your localhost Sitecore instance. Run the below command:

    ngrok http --host-header=rewrite <your-sitecore-domain>:443

enter image description here

  • You will get a random ngrok.io URL which is pointing to your localhost instance. You can access that URL from anywhere. It means your localhost Sitecore instance now has a public URL.

  • Update the <app-name>.config in the NextJS application with the new hostname.

enter image description here

  • Update Sitecore API Host in .env file.
SITECORE_API_HOST= <The URL generated by NGRock>
  • Update the scjssconfig.json file

enter image description here

  • Now push the changes to Vercel.
1

Vercel is a SaaS hosting platform. You need to have a url to your GraphQL end point that is accessible over the internet. As Raman has shown, you can expose your local running CM instance. It is more common to have a deployed CM environment for your head application hosting to use tho.

As for your QA environment using SSO, your assumption is not correct. SSO only applies to those users logging into the admin side of Sitecore. Your Vercel app will be getting the content via the GraphQL endpoint (https://yoursitecorexmsite.com/sitecore/api/graph/edge). This endpoint uses an api key to allow access to the content. So the SSO will not make any difference.

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.