Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(deploy): Helm update to avoid losing CORS allowlist

justin2019d5e33ac3
diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts
index db9e5c3b7..c88b57f91 100644
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@ -118,9 +118,13 @@ function buildContentDisposition(filename: string) {
export function createApp() {
const app = new Hono<AppVariables>();
- const corsOrigins = process.env.CORS_ORIGINS
- ? process.env.CORS_ORIGINS.split(",").map((origin) => origin.trim())
- : undefined;
+ const corsOriginSource = [process.env.CORS_ORIGINS, process.env.KANEO_CLIENT_URL].find(
+ (value) => value?.trim(),
+ );
+ const corsOrigins = corsOriginSource
+ ?.split(",")
+ .map((origin) => origin.trim())
+ .filter(Boolean);
app.use(
"*",
diff --git a/charts/kaneo/templates/deployment.yaml b/charts/kaneo/templates/deployment.yaml
index c483de72f..6a5453cdd 100644
--- a/charts/kaneo/templates/deployment.yaml
+++ b/charts/kaneo/templates/deployment.yaml
@@ -1,3 +1,12 @@
+{{- $corsOrigins := .Values.kaneo.env.corsOrigins -}}
+{{- $corsOriginsValue := "" -}}
+{{- if kindIs "slice" $corsOrigins -}}
+ {{- $corsOriginsValue = join "," $corsOrigins -}}
+{{- else if $corsOrigins -}}
+ {{- $corsOriginsValue = $corsOrigins -}}
+{{- else if .Values.kaneo.env.clientUrl -}}
+ {{- $corsOriginsValue = .Values.kaneo.env.clientUrl -}}
+{{- end }}
apiVersion: apps/v1
kind: Deployment
metadata:
@@ -36,6 +45,8 @@ spec:
env:
- name: KANEO_CLIENT_URL
value: "{{ .Values.kaneo.env.clientUrl }}"
+ - name: CORS_ORIGINS
+ value: {{ $corsOriginsValue | quote }}
- name: AUTH_SECRET
{{- if .Values.kaneo.env.existingSecret.enabled }}
valueFrom:
diff --git a/charts/kaneo/values.yaml b/charts/kaneo/values.yaml
index d47ba991b..742557f3d 100644
--- a/charts/kaneo/values.yaml
+++ b/charts/kaneo/values.yaml
@@ -82,6 +82,9 @@ kaneo:
# Public URL of this Kaneo instance (e.g. https://kaneo.example.com)
# KANEO_API_URL is derived automatically as clientUrl/api if not set
clientUrl: ""
+ # Allowed CORS origins. Accepts a comma-separated string or YAML list.
+ # Defaults to clientUrl when left empty.
+ corsOrigins: []
# Must be at least 32 characters long for Better Auth
# Generate with: openssl rand -hex 32
authSecret: change_me_to_at_least_32_characters_long_string