feat(laravel): auto-set APP_URL from platform or custom domain
Inject APP_URL for Laravel/PHP apps when missing: on create from the platform subdomain, on custom-domain verification from the verified host, and at deploy time as a safety net. Never overwrites user-provided values. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import { Application } from './entities/application.entity';
|
||||
import { CreateApplicationDto, UpdateApplicationDto } from './dto/application.dto';
|
||||
import { ClustersService } from '../clusters/clusters.service';
|
||||
import { UserRole, DatabaseType, CustomDomainStatus, AppRuntime } from '../common/enums';
|
||||
import { ensureAppUrlEnv } from './app-url.util';
|
||||
|
||||
@Injectable()
|
||||
export class ApplicationsService {
|
||||
@@ -82,6 +83,9 @@ export class ApplicationsService {
|
||||
? 80
|
||||
: 3000;
|
||||
|
||||
const subdomain = `${dto.name}-${userId.split('-')[0]}`;
|
||||
const platformDomain = this.configService.get('platform.domain') || 'apps.cloudhost.ir';
|
||||
|
||||
const app = this.appsRepository.create({
|
||||
...dto,
|
||||
userId,
|
||||
@@ -90,9 +94,20 @@ export class ApplicationsService {
|
||||
dbUsername,
|
||||
dbPassword,
|
||||
port: dto.port ?? defaultPort,
|
||||
subdomain: `${dto.name}-${userId.split('-')[0]}`,
|
||||
subdomain,
|
||||
customDomain: customDomain || undefined,
|
||||
customDomainStatus: customDomain ? CustomDomainStatus.PENDING_DNS : CustomDomainStatus.NONE,
|
||||
envVars: ensureAppUrlEnv(
|
||||
{
|
||||
name: dto.name,
|
||||
runtime: dto.runtime,
|
||||
subdomain,
|
||||
customDomain: customDomain || undefined,
|
||||
customDomainStatus: customDomain ? CustomDomainStatus.PENDING_DNS : CustomDomainStatus.NONE,
|
||||
envVars: dto.envVars,
|
||||
},
|
||||
platformDomain,
|
||||
),
|
||||
});
|
||||
return this.appsRepository.save(app);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user