@progress/sitefinity-nextjs-sdk
Version:
Provides OOB widgets developed using the Next.js framework, which includes an abstraction layer for Sitefinity communication. Additionally, it offers an expanded API, typings, and tools for further development and integration.
30 lines (29 loc) • 1.1 kB
JavaScript
export class RootUrlService {
static getClientCmsUrl() {
let publicUrl = `${process.env['NEXT_PUBLIC_SF_CMS_URL'] || ''}`;
if (publicUrl.endsWith('/')) {
publicUrl = publicUrl.substring(0, publicUrl.length - 1);
}
return publicUrl;
}
static getClientServiceUrl() {
return `${RootUrlService.getClientCmsUrl()}/${RootUrlService.getWebServicePath()}`;
}
static getServerCmsUrl() {
let rootUrl = process.env['SF_CMS_URL'];
if (rootUrl && rootUrl.endsWith('/')) {
rootUrl = rootUrl.substring(0, rootUrl.length - 1);
}
return rootUrl;
}
static getServerCmsServiceUrl() {
return `${RootUrlService.getServerCmsUrl() || ''}/${RootUrlService.getWebServicePath()}`;
}
static getWebServicePath() {
return process?.env?.SF_WEBSERVICE_PATH ?
process.env.SF_WEBSERVICE_PATH.trim()[0] === '/' ?
process.env.SF_WEBSERVICE_PATH.trim().substring(1) :
process.env.SF_WEBSERVICE_PATH.trim() :
'api/default';
}
}