chore: allow user to connect subdomain of app domain.

Some apps (eg: tiredofit/docker-baserow) require multiple domains. To reduce friction for the user, we don't want to split the app into multiple sub-apps or require the user to manually change Nginx template config or mess with Le'tsEncrypt certs. The simplest solution is to allow users to add app's subdomain.

For Caprover's server with root domain is root.domain.com, we have app1 at app1.root.domain.com. Allow users to connect subdomain api.app1.root.domain.com.
This commit is contained in:
Long Nguyen
2021-05-04 20:28:31 +07:00
parent f5b9393e35
commit 109de8cac8
+2 -1
View File
@@ -275,6 +275,7 @@ class ServiceManager {
.then(function () {
const rootDomain = self.dataStore.getRootDomain()
const dotRootDomain = `.${rootDomain}`
const appDomain = appName + dotRootDomain
if (!customDomain || !/^[a-z0-9\-\.]+$/.test(customDomain)) {
throw ApiStatusCodes.createError(
@@ -301,7 +302,7 @@ class ServiceManager {
customDomain.indexOf(dotRootDomain) >= 0 &&
customDomain.indexOf(dotRootDomain) +
dotRootDomain.length ===
customDomain.length
appDomain.length
) {
throw ApiStatusCodes.createError(
ApiStatusCodes.STATUS_ERROR_BAD_NAME,