From 109de8cac8d5e01a01234e2f91ba42507e97d24c Mon Sep 17 00:00:00 2001 From: Long Nguyen Date: Tue, 4 May 2021 20:28:31 +0700 Subject: [PATCH] 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. --- src/user/ServiceManager.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/user/ServiceManager.ts b/src/user/ServiceManager.ts index 704ac94..a66ef5c 100644 --- a/src/user/ServiceManager.ts +++ b/src/user/ServiceManager.ts @@ -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,