Files
cloud-host/backend/helm/cloudhost-platform/templates/_helpers.tpl
T
keyhan 95d0b162c5 feat(panel): serve authenticated app on dedicated panel subdomain
Separate the marketing landing site from the authenticated app by host.
Next.js middleware reads PANEL_HOST/LANDING_HOST at runtime and redirects
authenticated routes (/dashboard, /login, /register) from the landing host
to the panel host, and the landing root on the panel host to /dashboard.
Disabled (single-origin) when PANEL_HOST is unset, so local dev is unchanged.

Helm: add ingress.panel.host with a third ingress rule + TLS host routing to
the frontend service, pass LANDING_HOST/PANEL_HOST to the frontend, and append
the panel origin to the backend CORS list (frontend URL stays first so
PLATFORM_DOMAIN resolution is unaffected).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 17:33:19 +03:30

112 lines
4.0 KiB
Smarty

{{- define "cloudhost-platform.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- define "cloudhost-platform.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- define "cloudhost-platform.namespace" -}}
{{- .Values.namespace | default "cloudhost" }}
{{- end }}
{{- define "cloudhost-platform.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" }}
{{- end }}
{{- define "cloudhost-platform.labels" -}}
helm.sh/chart: {{ include "cloudhost-platform.chart" . }}
{{ include "cloudhost-platform.selectorLabels" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{- define "cloudhost-platform.selectorLabels" -}}
app.kubernetes.io/name: {{ include "cloudhost-platform.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- define "cloudhost-platform.postgres.fullname" -}}
{{- printf "%s-postgres" (include "cloudhost-platform.fullname" .) }}
{{- end }}
{{- define "cloudhost-platform.redis.fullname" -}}
{{- printf "%s-redis" (include "cloudhost-platform.fullname" .) }}
{{- end }}
{{- define "cloudhost-platform.backend.fullname" -}}
{{- printf "%s-backend" (include "cloudhost-platform.fullname" .) }}
{{- end }}
{{- define "cloudhost-platform.frontend.fullname" -}}
{{- printf "%s-frontend" (include "cloudhost-platform.fullname" .) }}
{{- end }}
{{- define "cloudhost-platform.secretName" -}}
{{- printf "%s-secrets" (include "cloudhost-platform.fullname" .) }}
{{- end }}
{{- define "cloudhost-platform.tlsSecretName" -}}
{{- if .Values.ingress.tls.secretName }}
{{- .Values.ingress.tls.secretName }}
{{- else }}
{{- printf "%s-platform-tls" (include "cloudhost-platform.fullname" .) }}
{{- end }}
{{- end }}
{{- define "cloudhost-platform.urlScheme" -}}
{{- if and .Values.ingress.enabled .Values.ingress.tls.enabled }}https{{- else }}http{{- end }}
{{- end }}
{{- define "cloudhost-platform.frontendPublicUrl" -}}
{{- $scheme := include "cloudhost-platform.urlScheme" . -}}
{{- if .Values.ingress.enabled }}
{{- if .Values.ingress.singleHost.enabled }}
{{- printf "%s://%s" $scheme .Values.ingress.singleHost.host }}
{{- else }}
{{- printf "%s://%s" $scheme .Values.ingress.frontend.host }}
{{- end }}
{{- else }}
{{- printf "http://%s-frontend.%s.svc.cluster.local:3000" (include "cloudhost-platform.fullname" .) (include "cloudhost-platform.namespace" .) }}
{{- end }}
{{- end }}
{{- /*
Comma-separated CORS origins for the backend's FRONTEND_URL.
The frontend (landing) URL MUST stay first: configuration.ts derives
PLATFORM_DOMAIN / preview domain from the first entry only. The panel host
(when configured) is appended as an additional allowed origin.
*/ -}}
{{- define "cloudhost-platform.corsOrigins" -}}
{{- $scheme := include "cloudhost-platform.urlScheme" . -}}
{{- $origins := list (include "cloudhost-platform.frontendPublicUrl" .) -}}
{{- if and .Values.ingress.enabled .Values.ingress.panel.host -}}
{{- $origins = append $origins (printf "%s://%s" $scheme .Values.ingress.panel.host) -}}
{{- end -}}
{{- join "," $origins -}}
{{- end }}
{{- define "cloudhost-platform.apiPublicUrl" -}}
{{- $scheme := include "cloudhost-platform.urlScheme" . -}}
{{- if .Values.ingress.enabled }}
{{- if .Values.ingress.singleHost.enabled }}
{{- printf "%s://%s%s" $scheme .Values.ingress.singleHost.host .Values.ingress.singleHost.apiPath }}
{{- else }}
{{- printf "%s://%s" $scheme .Values.ingress.api.host }}
{{- end }}
{{- else }}
{{- printf "http://%s-backend.%s.svc.cluster.local:4000" (include "cloudhost-platform.fullname" .) (include "cloudhost-platform.namespace" .) }}
{{- end }}
{{- end }}
{{- define "cloudhost-platform.backendImage" -}}
{{- printf "%s:%s" .Values.images.backend.repository .Values.images.backend.tag }}
{{- end }}
{{- define "cloudhost-platform.frontendImage" -}}
{{- printf "%s:%s" .Values.images.frontend.repository .Values.images.frontend.tag }}
{{- end }}