I have some code which integrates with a third party service by exposing webhooks (REST Methods) via a public (non-authenticated) site. I'm trying to figure out how this should work as part of automated build testing, as well as an unlocked package.
To begin with, I have an SFDX project which includes the Apex Class containing the REST methods, and which contains a public site definition (sites/Webhook_Service.site-meta.xml
). If I create a new scratch org and try to push the code, I get an error for the .site-meta.xml
file:
The Force.com Site subdomain has not been set in the organization
If I open the org and view the Sites page in Setup (LEX Setup -> User Interface -> Sites and Domains -> Sites), I am prompted to create a subdomain before I can create a Site. Once I set a subdomain name, then force:org:push
succeeds. This confirms to me that I need the "Site Subdomain" specified in the org before I can push the Site definition. As I understand it, this Site Subdomain cannot be set/created via Metadata API, and I have found no way to specify via SFDX either. Is that correct? Is there any way around this, for example, in order to do automated builds with SFDX?
It occurs to me that an unlocked package which contains a .site-meta.xml
will not successfully deploy unless a user has already set the Site Subdomain prior to trying to install the package. In the case of an unlocked package (as opposed to an automated SFDX build), I suppose it makes sense to call the setting of the Site Subdomain a prerequisite for the use of the unlocked Package. Is this considered best practice, or would be better to require the user to create their own public site?