What is absolute endpoint for CMS React serverless functions

I am trying to make a call from my CMS React project to a serverless endpoint. The same code is a relative URL which fails during testing.

Here’s my serverless.json

{
 "appFunctions": {
 "loadItem": {
 "file": "out/loadItem.js",
 "endpoint": {
 "path": "loadItem",
 "method": ["GET"]
 }
 }
 }
}

I see two different url schemas in docs:

`//{domainName}/_hcms/api/loadItem`

and

`/hs/serverless/loadItem`

I am not sure what “domainName” is - this is a demo account. If I do ‘hubspot.com’ then the respone says “The endpoint GET loadItem has not been configured for portal”

If I try the second one with “hubspot.com” it yields

context: { PATH: [ ‘loadItem’ ], METHOD: [ ‘GET’ ] },
category: ‘OBJECT_NOT_FOUND’,
subCategory: ‘ServerlessGatewayErrorType.GATEWAY_NOT_FOUND’

Any idea what correct absolute endpoint is?

Answering my own question after testing. I got the URL of a landing page using the “copy link” button in the preview and used that domain with the `hs/serverless` path such as:

“https://hubspot-demo-account-foo.hubspotpagebuilder.com/hs/serverless/myFuncEndpoint”

Adding a note that a GET request will work from the page builder but a POST will encounter CORS errors so you will need to preview the page (so homepagebuilder.com) to get it to work. If you do relative URL it should work in the preview but the absolute URL does allow GET from other domains such as local or page builder.

Adding another note that if you are using SSR (getServerSideProps) to fetch then an absolute URL is necessary since the server doesnt’ have one.