Starting/Launching the headless app
- Sridharan Padmanabhan
- Nov 29, 2024
- 2 min read
Updated: Dec 13, 2024
Prerequisites:
A running instance of Sitecore, with headless rendering installed.
A headless app created using the JSS CLI.
Connection set up between the headless app and Sitecore.
Config and App deployed to Sitecore
You can navigate to the previous articles from this article for doing the same.
Given your Sitecore and headless app are connected, and config and the app are deployed.
Running the app locally -
In order to run the app locally, run the following command in a terminal
jss start: connected
This would start the headless app on the default port, most commonly, https://localhost:3000
The app would be connected to Sitecore using the credentials we earlier specified in the .env file.
The app will start connecting to the Sitecore root item specified in the <app> configuration section in the <your headless app name>.config at ./sitecore/config/<your headless app name>.config
Running the app on the Site domain.
The <site> configuration on the <your headless app name>.config would contain definitions for your site's host name and start item.
My Site definition looks like this:
<site patch:before="site[@name='website']"
inherits="website"
name="sitecore-jss-app"
hostName="sitecorejssdemo.local"
rootPath="/sitecore/content/sitecore-jss-app"
startItem="/home"
database="master" />
And, once I have my config and the app deployed, I can access my host name as per this config, sitecorejssdemo.local to load the headless app.
Common errors while trying to start the app
the Sitecore headless app is accessible on https://localhost:3000, but does not work while accessing using the hostname (custom domain)
Solution:
Make sure the domain is hosted and is being served from the local IIS. Make sure the domain is added as a binding to your running Sitecore instance.
Make sure the custom domain is hitting your local IP, by spoofing the domain to 127.0.0.1 on your "hosts" file.
Make sure your app and configs are deployed, check for the config files in the folder C:\inetpub\wwwroot\<Your Sitecore directory>\App_Config\Include\zzz... and the compiled app code in the folder C:\inetpub\wwwroot\<Your Sitecore directory>\dist
Comments