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>
This commit is contained in:
keyhan
2026-06-16 17:33:19 +03:30
parent 37c103fa20
commit 95d0b162c5
6 changed files with 101 additions and 8 deletions
@@ -74,6 +74,21 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- 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 }}
@@ -79,7 +79,7 @@ spec:
name: {{ include "cloudhost-platform.secretName" . }}
key: jwt-refresh-secret
- name: FRONTEND_URL
value: {{ include "cloudhost-platform.frontendPublicUrl" . | quote }}
value: {{ include "cloudhost-platform.corsOrigins" . | quote }}
{{- range $key, $val := .Values.backend.env }}
- name: {{ $key }}
value: {{ $val | quote }}
@@ -28,6 +28,14 @@ spec:
value: "3000"
- name: HOSTNAME
value: "0.0.0.0"
{{- if .Values.ingress.panel.host }}
# Host-based separation: landing on frontend.host, authenticated
# panel on panel.host. Read by Next.js middleware at runtime.
- name: LANDING_HOST
value: {{ .Values.ingress.frontend.host | quote }}
- name: PANEL_HOST
value: {{ .Values.ingress.panel.host | quote }}
{{- end }}
livenessProbe:
httpGet:
path: /
@@ -25,6 +25,9 @@ spec:
- {{ .Values.ingress.singleHost.host | quote }}
{{- else }}
- {{ .Values.ingress.frontend.host | quote }}
{{- if .Values.ingress.panel.host }}
- {{ .Values.ingress.panel.host | quote }}
{{- end }}
- {{ .Values.ingress.api.host | quote }}
{{- end }}
secretName: {{ include "cloudhost-platform.tlsSecretName" . }}
@@ -59,6 +62,18 @@ spec:
name: {{ include "cloudhost-platform.frontend.fullname" . }}
port:
number: 3000
{{- if .Values.ingress.panel.host }}
- host: {{ .Values.ingress.panel.host | quote }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ include "cloudhost-platform.frontend.fullname" . }}
port:
number: 3000
{{- end }}
- host: {{ .Values.ingress.api.host | quote }}
http:
paths:
@@ -78,6 +78,10 @@ ingress:
className: nginx
frontend:
host: platform.cloudhost.local
# Optional dedicated host for the authenticated panel. Empty = disabled
# (single-origin, dev). Production (abrban): panel.abrban.com
panel:
host: ""
api:
host: api.cloudhost.local
singleHost: